Skip to content

Commit 2dc2ecf

Browse files
Andrew Boieandrewboie
authored andcommitted
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 <[email protected]>
1 parent 2f3a89f commit 2dc2ecf

File tree

13 files changed

+53
-53
lines changed

13 files changed

+53
-53
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ if(CONFIG_USERSPACE)
986986
${PROCESS_GPERF}
987987
-i ${OUTPUT_SRC_PRE}
988988
-o ${OUTPUT_SRC}
989-
-p "struct _k_object"
989+
-p "struct z_object"
990990
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
991991
DEPENDS output_src_pre ${OUTPUT_SRC_PRE}
992992
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}

doc/guides/documentation/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ For example::
396396

397397
.. code-block:: c
398398

399-
struct _k_object {
399+
struct z_object {
400400
char *name;
401401
u8_t perms[CONFIG_MAX_THREAD_BYTES];
402402
u8_t type;
@@ -412,7 +412,7 @@ This would be rendered as:
412412

413413
.. code-block:: c
414414
415-
struct _k_object {
415+
struct z_object {
416416
char *name;
417417
u8_t perms[CONFIG_MAX_THREAD_BYTES];
418418
u8_t type;

doc/reference/usermode/kernelobjects.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ be prevented. When a device struct is found, its API pointer is examined to
116116
determine what subsystem the driver belongs to.
117117

118118
The table itself maps kernel object memory addresses to instances of
119-
:c:type:`struct _k_object`, which has all the metadata for that object. This
119+
:c:type:`struct z_object`, which has all the metadata for that object. This
120120
includes:
121121

122122
* A bitfield indicating permissions on that object. All threads have a

include/kernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ union z_object_data {
186186

187187
/* Table generated by gperf, these objects are retrieved via
188188
* z_object_find() */
189-
struct _k_object {
189+
struct z_object {
190190
void *name;
191191
u8_t perms[CONFIG_MAX_THREAD_BYTES];
192192
u8_t type;

include/syscall_handler.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ enum _obj_init_check {
4646
* -EPERM If the caller does not have permissions
4747
* -EINVAL Object is not initialized
4848
*/
49-
int z_object_validate(struct _k_object *ko, enum k_objects otype,
50-
enum _obj_init_check init);
49+
int z_object_validate(struct z_object *ko, enum k_objects otype,
50+
enum _obj_init_check init);
5151

5252
/**
5353
* Dump out error information on failed z_object_validate() call
5454
*
5555
* @param retval Return value from z_object_validate()
5656
* @param obj Kernel object we were trying to verify
57-
* @param ko If retval=-EPERM, struct _k_object * that was looked up, or NULL
57+
* @param ko If retval=-EPERM, struct z_object * that was looked up, or NULL
5858
* @param otype Expected type of the kernel object
5959
*/
60-
extern void z_dump_object_error(int retval, void *obj, struct _k_object *ko,
61-
enum k_objects otype);
60+
extern void z_dump_object_error(int retval, void *obj, struct z_object *ko,
61+
enum k_objects otype);
6262

6363
/**
6464
* Kernel object validation function
@@ -70,14 +70,14 @@ extern void z_dump_object_error(int retval, void *obj, struct _k_object *ko,
7070
* @return Kernel object's metadata, or NULL if the parameter wasn't the
7171
* memory address of a kernel object
7272
*/
73-
extern struct _k_object *z_object_find(void *obj);
73+
extern struct z_object *z_object_find(void *obj);
7474

75-
typedef void (*_wordlist_cb_func_t)(struct _k_object *ko, void *context);
75+
typedef void (*_wordlist_cb_func_t)(struct z_object *ko, void *context);
7676

7777
/**
7878
* Iterate over all the kernel object metadata in the system
7979
*
80-
* @param func function to run on each struct _k_object
80+
* @param func function to run on each struct z_object
8181
* @param context Context pointer to pass to each invocation
8282
*/
8383
extern void z_object_wordlist_foreach(_wordlist_cb_func_t func, void *context);
@@ -97,15 +97,15 @@ extern void z_thread_perms_inherit(struct k_thread *parent,
9797
* @param ko Kernel object metadata to update
9898
* @param thread The thread to grant permission
9999
*/
100-
extern void z_thread_perms_set(struct _k_object *ko, struct k_thread *thread);
100+
extern void z_thread_perms_set(struct z_object *ko, struct k_thread *thread);
101101

102102
/**
103103
* Revoke a thread's permission to a kernel object
104104
*
105105
* @param ko Kernel object metadata to update
106106
* @param thread The thread to grant permission
107107
*/
108-
extern void z_thread_perms_clear(struct _k_object *ko, struct k_thread *thread);
108+
extern void z_thread_perms_clear(struct z_object *ko, struct k_thread *thread);
109109

110110
/*
111111
* 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);
393393
#define Z_SYSCALL_MEMORY_ARRAY_WRITE(ptr, nmemb, size) \
394394
Z_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, 1)
395395

396-
static inline int z_obj_validation_check(struct _k_object *ko,
397-
void *obj,
398-
enum k_objects otype,
399-
enum _obj_init_check init)
396+
static inline int z_obj_validation_check(struct z_object *ko,
397+
void *obj,
398+
enum k_objects otype,
399+
enum _obj_init_check init)
400400
{
401401
int ret;
402402

kernel/futex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
static struct z_futex_data *k_futex_find_data(struct k_futex *futex)
1616
{
17-
struct _k_object *obj;
17+
struct z_object *obj;
1818

1919
obj = z_object_find(futex);
2020
if (obj == NULL || obj->type != K_OBJ_FUTEX) {

kernel/sched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ int z_impl_k_thread_join(struct k_thread *thread, s32_t timeout)
14551455
*/
14561456
static bool thread_obj_validate(struct k_thread *thread)
14571457
{
1458-
struct _k_object *ko = z_object_find(thread);
1458+
struct z_object *ko = z_object_find(thread);
14591459
int ret = z_object_validate(ko, K_OBJ_THREAD, _OBJ_INIT_TRUE);
14601460

14611461
switch (ret) {

kernel/thread.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ static inline int z_vrfy_k_thread_name_copy(k_tid_t thread,
325325
{
326326
#ifdef CONFIG_THREAD_NAME
327327
size_t len;
328-
struct _k_object *ko = z_object_find(thread);
328+
struct z_object *ko = z_object_find(thread);
329329

330330
/* Special case: we allow reading the names of initialized threads
331331
* 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,
642642
int prio, u32_t options, s32_t delay)
643643
{
644644
size_t total_size;
645-
struct _k_object *stack_object;
645+
struct z_object *stack_object;
646646

647647
/* The thread and stack objects *must* be in an uninitialized state */
648648
Z_OOPS(Z_SYSCALL_OBJ_NEVER_INIT(new_thread, K_OBJ_THREAD));

kernel/userspace.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static struct k_spinlock obj_lock; /* kobj struct data */
5858
extern u8_t _thread_idx_map[CONFIG_MAX_THREAD_BYTES];
5959
#endif
6060

61-
static void clear_perms_cb(struct _k_object *ko, void *ctx_ptr);
61+
static void clear_perms_cb(struct z_object *ko, void *ctx_ptr);
6262

6363
const char *otype_to_str(enum k_objects otype)
6464
{
@@ -92,13 +92,13 @@ struct perm_ctx {
9292

9393
#ifdef CONFIG_DYNAMIC_OBJECTS
9494
struct dyn_obj {
95-
struct _k_object kobj;
95+
struct z_object kobj;
9696
sys_dnode_t obj_list;
9797
struct rbnode node; /* must be immediately before data member */
9898
u8_t data[]; /* The object itself */
9999
};
100100

101-
extern struct _k_object *z_object_gperf_find(void *obj);
101+
extern struct z_object *z_object_gperf_find(void *obj);
102102
extern void z_object_gperf_wordlist_foreach(_wordlist_cb_func_t func,
103103
void *context);
104104

@@ -307,9 +307,9 @@ void k_object_free(void *obj)
307307
}
308308
}
309309

310-
struct _k_object *z_object_find(void *obj)
310+
struct z_object *z_object_find(void *obj)
311311
{
312-
struct _k_object *ret;
312+
struct z_object *ret;
313313

314314
ret = z_object_gperf_find(obj);
315315

@@ -342,7 +342,7 @@ void z_object_wordlist_foreach(_wordlist_cb_func_t func, void *context)
342342

343343
static unsigned int thread_index_get(struct k_thread *thread)
344344
{
345-
struct _k_object *ko;
345+
struct z_object *ko;
346346

347347
ko = z_object_find(thread);
348348

@@ -353,7 +353,7 @@ static unsigned int thread_index_get(struct k_thread *thread)
353353
return ko->data.thread_id;
354354
}
355355

356-
static void unref_check(struct _k_object *ko, uintptr_t index)
356+
static void unref_check(struct z_object *ko, uintptr_t index)
357357
{
358358
k_spinlock_key_t key = k_spin_lock(&obj_lock);
359359

@@ -401,7 +401,7 @@ static void unref_check(struct _k_object *ko, uintptr_t index)
401401
k_spin_unlock(&obj_lock, key);
402402
}
403403

404-
static void wordlist_cb(struct _k_object *ko, void *ctx_ptr)
404+
static void wordlist_cb(struct z_object *ko, void *ctx_ptr)
405405
{
406406
struct perm_ctx *ctx = (struct perm_ctx *)ctx_ptr;
407407

@@ -424,7 +424,7 @@ void z_thread_perms_inherit(struct k_thread *parent, struct k_thread *child)
424424
}
425425
}
426426

427-
void z_thread_perms_set(struct _k_object *ko, struct k_thread *thread)
427+
void z_thread_perms_set(struct z_object *ko, struct k_thread *thread)
428428
{
429429
int index = thread_index_get(thread);
430430

@@ -433,7 +433,7 @@ void z_thread_perms_set(struct _k_object *ko, struct k_thread *thread)
433433
}
434434
}
435435

436-
void z_thread_perms_clear(struct _k_object *ko, struct k_thread *thread)
436+
void z_thread_perms_clear(struct z_object *ko, struct k_thread *thread)
437437
{
438438
int index = thread_index_get(thread);
439439

@@ -443,7 +443,7 @@ void z_thread_perms_clear(struct _k_object *ko, struct k_thread *thread)
443443
}
444444
}
445445

446-
static void clear_perms_cb(struct _k_object *ko, void *ctx_ptr)
446+
static void clear_perms_cb(struct z_object *ko, void *ctx_ptr)
447447
{
448448
uintptr_t id = (uintptr_t)ctx_ptr;
449449

@@ -459,7 +459,7 @@ void z_thread_perms_all_clear(struct k_thread *thread)
459459
}
460460
}
461461

462-
static int thread_perms_test(struct _k_object *ko)
462+
static int thread_perms_test(struct z_object *ko)
463463
{
464464
int index;
465465

@@ -474,7 +474,7 @@ static int thread_perms_test(struct _k_object *ko)
474474
return 0;
475475
}
476476

477-
static void dump_permission_error(struct _k_object *ko)
477+
static void dump_permission_error(struct z_object *ko)
478478
{
479479
int index = thread_index_get(_current);
480480
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)
483483
LOG_HEXDUMP_ERR(ko->perms, sizeof(ko->perms), "permission bitmap");
484484
}
485485

486-
void z_dump_object_error(int retval, void *obj, struct _k_object *ko,
486+
void z_dump_object_error(int retval, void *obj, struct z_object *ko,
487487
enum k_objects otype)
488488
{
489489
switch (retval) {
@@ -507,7 +507,7 @@ void z_dump_object_error(int retval, void *obj, struct _k_object *ko,
507507

508508
void z_impl_k_object_access_grant(void *object, struct k_thread *thread)
509509
{
510-
struct _k_object *ko = z_object_find(object);
510+
struct z_object *ko = z_object_find(object);
511511

512512
if (ko != NULL) {
513513
z_thread_perms_set(ko, thread);
@@ -516,7 +516,7 @@ void z_impl_k_object_access_grant(void *object, struct k_thread *thread)
516516

517517
void k_object_access_revoke(void *object, struct k_thread *thread)
518518
{
519-
struct _k_object *ko = z_object_find(object);
519+
struct z_object *ko = z_object_find(object);
520520

521521
if (ko != NULL) {
522522
z_thread_perms_clear(ko, thread);
@@ -530,14 +530,14 @@ void z_impl_k_object_release(void *object)
530530

531531
void k_object_access_all_grant(void *object)
532532
{
533-
struct _k_object *ko = z_object_find(object);
533+
struct z_object *ko = z_object_find(object);
534534

535535
if (ko != NULL) {
536536
ko->flags |= K_OBJ_FLAG_PUBLIC;
537537
}
538538
}
539539

540-
int z_object_validate(struct _k_object *ko, enum k_objects otype,
540+
int z_object_validate(struct z_object *ko, enum k_objects otype,
541541
enum _obj_init_check init)
542542
{
543543
if (unlikely((ko == NULL) ||
@@ -572,7 +572,7 @@ int z_object_validate(struct _k_object *ko, enum k_objects otype,
572572

573573
void z_object_init(void *obj)
574574
{
575-
struct _k_object *ko;
575+
struct z_object *ko;
576576

577577
/* By the time we get here, if the caller was from userspace, all the
578578
* necessary checks have been done in z_object_validate(), which takes
@@ -597,7 +597,7 @@ void z_object_init(void *obj)
597597

598598
void z_object_recycle(void *obj)
599599
{
600-
struct _k_object *ko = z_object_find(obj);
600+
struct z_object *ko = z_object_find(obj);
601601

602602
if (ko != NULL) {
603603
(void)memset(ko->perms, 0, sizeof(ko->perms));
@@ -608,7 +608,7 @@ void z_object_recycle(void *obj)
608608

609609
void z_object_uninit(void *obj)
610610
{
611-
struct _k_object *ko;
611+
struct z_object *ko;
612612

613613
/* See comments in z_object_init() */
614614
ko = z_object_find(obj);

kernel/userspace_handler.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#include <syscall_handler.h>
99
#include <kernel_structs.h>
1010

11-
static struct _k_object *validate_any_object(void *obj)
11+
static struct z_object *validate_any_object(void *obj)
1212
{
13-
struct _k_object *ko;
13+
struct z_object *ko;
1414
int ret;
1515

1616
ko = z_object_find(obj);
@@ -39,7 +39,7 @@ static struct _k_object *validate_any_object(void *obj)
3939
static inline void z_vrfy_k_object_access_grant(void *object,
4040
struct k_thread *thread)
4141
{
42-
struct _k_object *ko;
42+
struct z_object *ko;
4343

4444
Z_OOPS(Z_SYSCALL_OBJ_INIT(thread, K_OBJ_THREAD));
4545
ko = validate_any_object(object);
@@ -51,7 +51,7 @@ static inline void z_vrfy_k_object_access_grant(void *object,
5151

5252
static inline void z_vrfy_k_object_release(void *object)
5353
{
54-
struct _k_object *ko;
54+
struct z_object *ko;
5555

5656
ko = validate_any_object((void *)object);
5757
Z_OOPS(Z_SYSCALL_VERIFY_MSG(ko != NULL, "object %p access denied",

0 commit comments

Comments
 (0)