Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
kobject_internal.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef ZEPHYR_INCLUDE_SYS_INTERNAL_KOBJECT_INTERNAL_H
7#define ZEPHYR_INCLUDE_SYS_INTERNAL_KOBJECT_INTERNAL_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
19#if defined(CONFIG_USERSPACE) || defined(__DOXYGEN__)
20#if defined(CONFIG_GEN_PRIV_STACKS) || defined(__DOXYGEN__)
21/* Metadata struct for K_OBJ_THREAD_STACK_ELEMENT */
22struct z_stack_data {
23 /* Size of the entire stack object, including reserved areas */
24 size_t size;
25
26 /* Stack buffer for privilege mode elevations */
27 uint8_t *priv;
28};
29#endif /* CONFIG_GEN_PRIV_STACKS */
30
31/* Object extra data. Only some objects use this, determined by object type */
33 /* Backing mutex for K_OBJ_SYS_MUTEX */
34 struct k_mutex *mutex;
35
36 /* Numerical thread ID for K_OBJ_THREAD */
37 unsigned int thread_id;
38
39#if defined(CONFIG_GEN_PRIV_STACKS) || defined(__DOXYGEN__)
40 /* Metadata for K_OBJ_THREAD_STACK_ELEMENT */
41 const struct z_stack_data *stack_data;
42#else
43 /* Stack buffer size for K_OBJ_THREAD_STACK_ELEMENT */
44 size_t stack_size;
45#endif /* CONFIG_GEN_PRIV_STACKS */
46
47 /* Futex wait queue and spinlock for K_OBJ_FUTEX */
48 struct z_futex_data *futex_data;
49
50 /* All other objects */
51 int unused;
52};
53
61struct k_object {
62 void *name;
63 uint8_t perms[CONFIG_MAX_THREAD_BYTES];
67} __packed __aligned(4);
68
71 void * const *objects;
72};
73
74
87void k_object_init(const void *obj);
88
89
90#else
91/* LCOV_EXCL_START */
92static inline void k_object_init(const void *obj)
93{
94 ARG_UNUSED(obj);
95}
96/* LCOV_EXCL_STOP */
97#endif /* !CONFIG_USERSPACE */
98
99#ifdef CONFIG_DYNAMIC_OBJECTS
123struct k_object *k_object_create_dynamic_aligned(size_t align, size_t size);
124
147static inline struct k_object *k_object_create_dynamic(size_t size)
148{
149 return k_object_create_dynamic_aligned(0, size);
150}
151
152#else
153
154/* LCOV_EXCL_START */
155static inline struct k_object *k_object_create_dynamic_aligned(size_t align,
156 size_t size)
157{
158 ARG_UNUSED(align);
159 ARG_UNUSED(size);
160
161 return NULL;
162}
163
164static inline struct k_object *k_object_create_dynamic(size_t size)
165{
166 ARG_UNUSED(size);
167
168 return NULL;
169}
170
171/* LCOV_EXCL_STOP */
172#endif /* CONFIG_DYNAMIC_OBJECTS */
173
176#ifdef __cplusplus
177}
178#endif
179
180#endif
static struct k_object * k_object_create_dynamic(size_t size)
Definition kobject_internal.h:164
void k_object_init(const void *obj)
Lookup a kernel object and init its metadata if it exists.
static struct k_object * k_object_create_dynamic_aligned(size_t align, size_t size)
Definition kobject_internal.h:155
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Mutex Structure.
Definition kernel.h:2917
Definition kobject_internal.h:69
struct k_thread * thread
Definition kobject_internal.h:70
void *const * objects
Definition kobject_internal.h:71
Table generated by gperf, these objects are retrieved via k_object_find().
Definition kobject_internal.h:61
uint8_t flags
Definition kobject_internal.h:65
uint8_t type
Definition kobject_internal.h:64
uint8_t perms[CONFIG_MAX_THREAD_BYTES]
Definition kobject_internal.h:63
void * name
Definition kobject_internal.h:62
union k_object_data data
Definition kobject_internal.h:66
Thread Structure.
Definition thread.h:259
Definition kobject_internal.h:32
int unused
Definition kobject_internal.h:51
struct k_mutex * mutex
Definition kobject_internal.h:34
const struct z_stack_data * stack_data
Definition kobject_internal.h:41
unsigned int thread_id
Definition kobject_internal.h:37
struct z_futex_data * futex_data
Definition kobject_internal.h:48