kernel: rename struct _k_object

Private type, internal to the kernel, not directly associated
with any k_object_* APIs. Is the return value of z_object_find().
Rename to struct z_object.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-03-11 07:13:07 -07:00 committed by Andrew Boie
commit 2dc2ecfb60
13 changed files with 53 additions and 53 deletions

View file

@ -986,7 +986,7 @@ if(CONFIG_USERSPACE)
${PROCESS_GPERF}
-i ${OUTPUT_SRC_PRE}
-o ${OUTPUT_SRC}
-p "struct _k_object"
-p "struct z_object"
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
DEPENDS output_src_pre ${OUTPUT_SRC_PRE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}

View file

@ -396,7 +396,7 @@ For example::
.. code-block:: c
struct _k_object {
struct z_object {
char *name;
u8_t perms[CONFIG_MAX_THREAD_BYTES];
u8_t type;
@ -412,7 +412,7 @@ This would be rendered as:
.. code-block:: c
struct _k_object {
struct z_object {
char *name;
u8_t perms[CONFIG_MAX_THREAD_BYTES];
u8_t type;

View file

@ -116,7 +116,7 @@ be prevented. When a device struct is found, its API pointer is examined to
determine what subsystem the driver belongs to.
The table itself maps kernel object memory addresses to instances of
:c:type:`struct _k_object`, which has all the metadata for that object. This
:c:type:`struct z_object`, which has all the metadata for that object. This
includes:
* A bitfield indicating permissions on that object. All threads have a

View file

@ -186,7 +186,7 @@ union z_object_data {
/* Table generated by gperf, these objects are retrieved via
* z_object_find() */
struct _k_object {
struct z_object {
void *name;
u8_t perms[CONFIG_MAX_THREAD_BYTES];
u8_t type;

View file

@ -46,19 +46,19 @@ enum _obj_init_check {
* -EPERM If the caller does not have permissions
* -EINVAL Object is not initialized
*/
int z_object_validate(struct _k_object *ko, enum k_objects otype,
enum _obj_init_check init);
int z_object_validate(struct z_object *ko, enum k_objects otype,
enum _obj_init_check init);
/**
* Dump out error information on failed z_object_validate() call
*
* @param retval Return value from z_object_validate()
* @param obj Kernel object we were trying to verify
* @param ko If retval=-EPERM, struct _k_object * that was looked up, or NULL
* @param ko If retval=-EPERM, struct z_object * that was looked up, or NULL
* @param otype Expected type of the kernel object
*/
extern void z_dump_object_error(int retval, void *obj, struct _k_object *ko,
enum k_objects otype);
extern void z_dump_object_error(int retval, void *obj, struct z_object *ko,
enum k_objects otype);
/**
* Kernel object validation function
@ -70,14 +70,14 @@ extern void z_dump_object_error(int retval, void *obj, struct _k_object *ko,
* @return Kernel object's metadata, or NULL if the parameter wasn't the
* memory address of a kernel object
*/
extern struct _k_object *z_object_find(void *obj);
extern struct z_object *z_object_find(void *obj);
typedef void (*_wordlist_cb_func_t)(struct _k_object *ko, void *context);
typedef void (*_wordlist_cb_func_t)(struct z_object *ko, void *context);
/**
* Iterate over all the kernel object metadata in the system
*
* @param func function to run on each struct _k_object
* @param func function to run on each struct z_object
* @param context Context pointer to pass to each invocation
*/
extern void z_object_wordlist_foreach(_wordlist_cb_func_t func, void *context);
@ -97,7 +97,7 @@ extern void z_thread_perms_inherit(struct k_thread *parent,
* @param ko Kernel object metadata to update
* @param thread The thread to grant permission
*/
extern void z_thread_perms_set(struct _k_object *ko, struct k_thread *thread);
extern void z_thread_perms_set(struct z_object *ko, struct k_thread *thread);
/**
* Revoke a thread's permission to a kernel object
@ -105,7 +105,7 @@ extern void z_thread_perms_set(struct _k_object *ko, struct k_thread *thread);
* @param ko Kernel object metadata to update
* @param thread The thread to grant permission
*/
extern void z_thread_perms_clear(struct _k_object *ko, struct k_thread *thread);
extern void z_thread_perms_clear(struct z_object *ko, struct k_thread *thread);
/*
* Revoke access to all objects for the provided thread
@ -393,10 +393,10 @@ extern int z_user_string_copy(char *dst, const char *src, size_t maxlen);
#define Z_SYSCALL_MEMORY_ARRAY_WRITE(ptr, nmemb, size) \
Z_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, 1)
static inline int z_obj_validation_check(struct _k_object *ko,
void *obj,
enum k_objects otype,
enum _obj_init_check init)
static inline int z_obj_validation_check(struct z_object *ko,
void *obj,
enum k_objects otype,
enum _obj_init_check init)
{
int ret;

View file

@ -14,7 +14,7 @@
static struct z_futex_data *k_futex_find_data(struct k_futex *futex)
{
struct _k_object *obj;
struct z_object *obj;
obj = z_object_find(futex);
if (obj == NULL || obj->type != K_OBJ_FUTEX) {

View file

@ -1455,7 +1455,7 @@ out:
*/
static bool thread_obj_validate(struct k_thread *thread)
{
struct _k_object *ko = z_object_find(thread);
struct z_object *ko = z_object_find(thread);
int ret = z_object_validate(ko, K_OBJ_THREAD, _OBJ_INIT_TRUE);
switch (ret) {

View file

@ -325,7 +325,7 @@ static inline int z_vrfy_k_thread_name_copy(k_tid_t thread,
{
#ifdef CONFIG_THREAD_NAME
size_t len;
struct _k_object *ko = z_object_find(thread);
struct z_object *ko = z_object_find(thread);
/* Special case: we allow reading the names of initialized threads
* even if we don't have permission on them
@ -642,7 +642,7 @@ k_tid_t z_vrfy_k_thread_create(struct k_thread *new_thread,
int prio, u32_t options, s32_t delay)
{
size_t total_size;
struct _k_object *stack_object;
struct z_object *stack_object;
/* The thread and stack objects *must* be in an uninitialized state */
Z_OOPS(Z_SYSCALL_OBJ_NEVER_INIT(new_thread, K_OBJ_THREAD));

View file

@ -58,7 +58,7 @@ static struct k_spinlock obj_lock; /* kobj struct data */
extern u8_t _thread_idx_map[CONFIG_MAX_THREAD_BYTES];
#endif
static void clear_perms_cb(struct _k_object *ko, void *ctx_ptr);
static void clear_perms_cb(struct z_object *ko, void *ctx_ptr);
const char *otype_to_str(enum k_objects otype)
{
@ -92,13 +92,13 @@ struct perm_ctx {
#ifdef CONFIG_DYNAMIC_OBJECTS
struct dyn_obj {
struct _k_object kobj;
struct z_object kobj;
sys_dnode_t obj_list;
struct rbnode node; /* must be immediately before data member */
u8_t data[]; /* The object itself */
};
extern struct _k_object *z_object_gperf_find(void *obj);
extern struct z_object *z_object_gperf_find(void *obj);
extern void z_object_gperf_wordlist_foreach(_wordlist_cb_func_t func,
void *context);
@ -307,9 +307,9 @@ void k_object_free(void *obj)
}
}
struct _k_object *z_object_find(void *obj)
struct z_object *z_object_find(void *obj)
{
struct _k_object *ret;
struct z_object *ret;
ret = z_object_gperf_find(obj);
@ -342,7 +342,7 @@ void z_object_wordlist_foreach(_wordlist_cb_func_t func, void *context)
static unsigned int thread_index_get(struct k_thread *thread)
{
struct _k_object *ko;
struct z_object *ko;
ko = z_object_find(thread);
@ -353,7 +353,7 @@ static unsigned int thread_index_get(struct k_thread *thread)
return ko->data.thread_id;
}
static void unref_check(struct _k_object *ko, uintptr_t index)
static void unref_check(struct z_object *ko, uintptr_t index)
{
k_spinlock_key_t key = k_spin_lock(&obj_lock);
@ -401,7 +401,7 @@ out:
k_spin_unlock(&obj_lock, key);
}
static void wordlist_cb(struct _k_object *ko, void *ctx_ptr)
static void wordlist_cb(struct z_object *ko, void *ctx_ptr)
{
struct perm_ctx *ctx = (struct perm_ctx *)ctx_ptr;
@ -424,7 +424,7 @@ void z_thread_perms_inherit(struct k_thread *parent, struct k_thread *child)
}
}
void z_thread_perms_set(struct _k_object *ko, struct k_thread *thread)
void z_thread_perms_set(struct z_object *ko, struct k_thread *thread)
{
int index = thread_index_get(thread);
@ -433,7 +433,7 @@ void z_thread_perms_set(struct _k_object *ko, struct k_thread *thread)
}
}
void z_thread_perms_clear(struct _k_object *ko, struct k_thread *thread)
void z_thread_perms_clear(struct z_object *ko, struct k_thread *thread)
{
int index = thread_index_get(thread);
@ -443,7 +443,7 @@ void z_thread_perms_clear(struct _k_object *ko, struct k_thread *thread)
}
}
static void clear_perms_cb(struct _k_object *ko, void *ctx_ptr)
static void clear_perms_cb(struct z_object *ko, void *ctx_ptr)
{
uintptr_t id = (uintptr_t)ctx_ptr;
@ -459,7 +459,7 @@ void z_thread_perms_all_clear(struct k_thread *thread)
}
}
static int thread_perms_test(struct _k_object *ko)
static int thread_perms_test(struct z_object *ko)
{
int index;
@ -474,7 +474,7 @@ static int thread_perms_test(struct _k_object *ko)
return 0;
}
static void dump_permission_error(struct _k_object *ko)
static void dump_permission_error(struct z_object *ko)
{
int index = thread_index_get(_current);
LOG_ERR("thread %p (%d) does not have permission on %s %p",
@ -483,7 +483,7 @@ static void dump_permission_error(struct _k_object *ko)
LOG_HEXDUMP_ERR(ko->perms, sizeof(ko->perms), "permission bitmap");
}
void z_dump_object_error(int retval, void *obj, struct _k_object *ko,
void z_dump_object_error(int retval, void *obj, struct z_object *ko,
enum k_objects otype)
{
switch (retval) {
@ -507,7 +507,7 @@ void z_dump_object_error(int retval, void *obj, struct _k_object *ko,
void z_impl_k_object_access_grant(void *object, struct k_thread *thread)
{
struct _k_object *ko = z_object_find(object);
struct z_object *ko = z_object_find(object);
if (ko != NULL) {
z_thread_perms_set(ko, thread);
@ -516,7 +516,7 @@ void z_impl_k_object_access_grant(void *object, struct k_thread *thread)
void k_object_access_revoke(void *object, struct k_thread *thread)
{
struct _k_object *ko = z_object_find(object);
struct z_object *ko = z_object_find(object);
if (ko != NULL) {
z_thread_perms_clear(ko, thread);
@ -530,14 +530,14 @@ void z_impl_k_object_release(void *object)
void k_object_access_all_grant(void *object)
{
struct _k_object *ko = z_object_find(object);
struct z_object *ko = z_object_find(object);
if (ko != NULL) {
ko->flags |= K_OBJ_FLAG_PUBLIC;
}
}
int z_object_validate(struct _k_object *ko, enum k_objects otype,
int z_object_validate(struct z_object *ko, enum k_objects otype,
enum _obj_init_check init)
{
if (unlikely((ko == NULL) ||
@ -572,7 +572,7 @@ int z_object_validate(struct _k_object *ko, enum k_objects otype,
void z_object_init(void *obj)
{
struct _k_object *ko;
struct z_object *ko;
/* By the time we get here, if the caller was from userspace, all the
* necessary checks have been done in z_object_validate(), which takes
@ -597,7 +597,7 @@ void z_object_init(void *obj)
void z_object_recycle(void *obj)
{
struct _k_object *ko = z_object_find(obj);
struct z_object *ko = z_object_find(obj);
if (ko != NULL) {
(void)memset(ko->perms, 0, sizeof(ko->perms));
@ -608,7 +608,7 @@ void z_object_recycle(void *obj)
void z_object_uninit(void *obj)
{
struct _k_object *ko;
struct z_object *ko;
/* See comments in z_object_init() */
ko = z_object_find(obj);

View file

@ -8,9 +8,9 @@
#include <syscall_handler.h>
#include <kernel_structs.h>
static struct _k_object *validate_any_object(void *obj)
static struct z_object *validate_any_object(void *obj)
{
struct _k_object *ko;
struct z_object *ko;
int ret;
ko = z_object_find(obj);
@ -39,7 +39,7 @@ static struct _k_object *validate_any_object(void *obj)
static inline void z_vrfy_k_object_access_grant(void *object,
struct k_thread *thread)
{
struct _k_object *ko;
struct z_object *ko;
Z_OOPS(Z_SYSCALL_OBJ_INIT(thread, K_OBJ_THREAD));
ko = validate_any_object(object);
@ -51,7 +51,7 @@ static inline void z_vrfy_k_object_access_grant(void *object,
static inline void z_vrfy_k_object_release(void *object)
{
struct _k_object *ko;
struct z_object *ko;
ko = validate_any_object((void *)object);
Z_OOPS(Z_SYSCALL_VERIFY_MSG(ko != NULL, "object %p access denied",

View file

@ -11,7 +11,7 @@
static struct k_mutex *get_k_mutex(struct sys_mutex *mutex)
{
struct _k_object *obj;
struct z_object *obj;
obj = z_object_find(mutex);
if (obj == NULL || obj->type != K_OBJ_SYS_MUTEX) {

View file

@ -111,7 +111,7 @@ header = """%compare-lengths
#include <syscall_handler.h>
#include <string.h>
%}
struct _k_object;
struct z_object;
"""
# Different versions of gperf have different prototypes for the lookup
@ -119,7 +119,7 @@ struct _k_object;
# turned into a string, we told gperf to expect binary strings that are not
# NULL-terminated.
footer = """%%
struct _k_object *z_object_gperf_find(void *obj)
struct z_object *z_object_gperf_find(void *obj)
{
return z_object_lookup((const char *)obj, sizeof(void *));
}
@ -136,7 +136,7 @@ void z_object_gperf_wordlist_foreach(_wordlist_cb_func_t func, void *context)
}
#ifndef CONFIG_DYNAMIC_OBJECTS
struct _k_object *z_object_find(void *obj)
struct z_object *z_object_find(void *obj)
ALIAS_OF(z_object_gperf_find);
void z_object_wordlist_foreach(_wordlist_cb_func_t func, void *context)

View file

@ -1123,7 +1123,7 @@ static struct k_sem recycle_sem;
void test_object_recycle(void)
{
struct _k_object *ko;
struct z_object *ko;
int perms_count = 0;
ko = z_object_find(&recycle_sem);