Zephyr Project API 4.3.2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
obj_core.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023, Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef __KERNEL_OBJ_CORE_H__
8#define __KERNEL_OBJ_CORE_H__
9
10#include <zephyr/sys/slist.h>
11
17
21#define K_OBJ_CORE(kobj) (&((kobj)->obj_core))
22
26#define K_OBJ_TYPE_ID_GEN(s) ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | (s[3]))
27
28/* Known kernel object types */
29
31#define K_OBJ_TYPE_CONDVAR_ID K_OBJ_TYPE_ID_GEN("COND")
33#define K_OBJ_TYPE_CPU_ID K_OBJ_TYPE_ID_GEN("CPU_")
35#define K_OBJ_TYPE_EVENT_ID K_OBJ_TYPE_ID_GEN("EVNT")
37#define K_OBJ_TYPE_FIFO_ID K_OBJ_TYPE_ID_GEN("FIFO")
39#define K_OBJ_TYPE_KERNEL_ID K_OBJ_TYPE_ID_GEN("KRNL")
41#define K_OBJ_TYPE_LIFO_ID K_OBJ_TYPE_ID_GEN("LIFO")
43#define K_OBJ_TYPE_MEM_BLOCK_ID K_OBJ_TYPE_ID_GEN("MBLK")
45#define K_OBJ_TYPE_MBOX_ID K_OBJ_TYPE_ID_GEN("MBOX")
47#define K_OBJ_TYPE_MEM_SLAB_ID K_OBJ_TYPE_ID_GEN("SLAB")
49#define K_OBJ_TYPE_MSGQ_ID K_OBJ_TYPE_ID_GEN("MSGQ")
51#define K_OBJ_TYPE_MUTEX_ID K_OBJ_TYPE_ID_GEN("MUTX")
53#define K_OBJ_TYPE_PIPE_ID K_OBJ_TYPE_ID_GEN("PIPE")
55#define K_OBJ_TYPE_SEM_ID K_OBJ_TYPE_ID_GEN("SEM4")
57#define K_OBJ_TYPE_STACK_ID K_OBJ_TYPE_ID_GEN("STCK")
59#define K_OBJ_TYPE_THREAD_ID K_OBJ_TYPE_ID_GEN("THRD")
61#define K_OBJ_TYPE_TIMER_ID K_OBJ_TYPE_ID_GEN("TIMR")
62
63struct k_obj_type;
64struct k_obj_core;
65
69
70#ifdef CONFIG_OBJ_CORE
71#define K_OBJ_CORE_INIT(_objp, _obj_type) \
72 extern struct k_obj_type _obj_type; \
73 k_obj_core_init(_objp, &_obj_type)
74
75#define K_OBJ_CORE_INIT_UNLINKED(_objp, _obj_type) \
76 extern struct k_obj_type _obj_type; \
77 z_obj_core_init_unlinked(_objp, &_obj_type)
78
79#define K_OBJ_CORE_LINK(objp) k_obj_core_link(objp)
80#else
81#define K_OBJ_CORE_INIT(objp, type) do { } while (0)
82#define K_OBJ_CORE_INIT_UNLINKED(objp, type) do { } while (0)
83#define K_OBJ_CORE_LINK(objp) do { } while (0)
84#endif /* CONFIG_OBJ_CORE */
85
89
94extern sys_slist_t z_obj_type_list;
95
98 size_t raw_size;
99 size_t query_size;
100
102 int (*raw)(struct k_obj_core *obj_core, void *stats);
104 int (*query)(struct k_obj_core *obj_core, void *stats);
106 int (*reset)(struct k_obj_core *obj_core);
108 int (*disable)(struct k_obj_core *obj_core);
110 int (*enable)(struct k_obj_core *obj_core);
111};
112
119#ifdef CONFIG_OBJ_CORE_STATS
121 struct k_obj_core_stats_desc *stats_desc;
122#endif /* CONFIG_OBJ_CORE_STATS */
123};
124
128 struct k_obj_type *type;
129#ifdef CONFIG_OBJ_CORE_STATS
130 void *stats;
131#endif /* CONFIG_OBJ_CORE_STATS */
132};
133
146struct k_obj_type *z_obj_type_init(struct k_obj_type *type,
147 uint32_t id, size_t off);
148
161
180 int (*func)(struct k_obj_core *, void *),
181 void *data);
182
202 int (*func)(struct k_obj_core *, void *),
203 void *data);
204
214void k_obj_core_init(struct k_obj_core *obj_core, struct k_obj_type *type);
215
226void k_obj_core_link(struct k_obj_core *obj_core);
227
238 struct k_obj_type *type);
239
249static inline void z_obj_core_init_unlinked(struct k_obj_core *obj_core,
250 struct k_obj_type *type)
251{
252 obj_core->type = type;
253#ifdef CONFIG_OBJ_CORE_STATS
254 obj_core->stats = NULL;
255#endif /* CONFIG_OBJ_CORE_STATS */
256}
257
259
269void k_obj_core_unlink(struct k_obj_core *obj_core);
270
272
278
279#ifdef CONFIG_OBJ_CORE_STATS
288static inline void k_obj_type_stats_init(struct k_obj_type *type,
289 struct k_obj_core_stats_desc *stats_desc)
290{
291 type->stats_desc = stats_desc;
292}
293
303static inline void k_obj_core_stats_init(struct k_obj_core *obj_core,
304 void *stats)
305{
306 obj_core->stats = stats;
307}
308#endif /* CONFIG_OBJ_CORE_STATS */
309
324int k_obj_core_stats_register(struct k_obj_core *obj_core, void *stats,
325 size_t stats_len);
326
340
356int k_obj_core_stats_raw(struct k_obj_core *obj_core, void *stats,
357 size_t stats_len);
358
375int k_obj_core_stats_query(struct k_obj_core *obj_core, void *stats,
376 size_t stats_len);
377
389int k_obj_core_stats_reset(struct k_obj_core *obj_core);
390
404
417
419#endif /* __KERNEL_OBJ_CORE_H__ */
irp nz macro MOVR cc s mov cc s endm endr irp aw macro LDR aa off
Definition asm-macro-32-bit-gnu.h:17
int k_obj_type_walk_locked(struct k_obj_type *type, int(*func)(struct k_obj_core *, void *), void *data)
Walk the object type's list of object cores.
struct k_obj_type * k_obj_type_find(uint32_t type_id)
Find a specific object type by ID.
int k_obj_type_walk_unlocked(struct k_obj_type *type, int(*func)(struct k_obj_core *, void *), void *data)
Walk the object type's list of object cores.
void k_obj_core_link(struct k_obj_core *obj_core)
Link the kernel object to the kernel object type list.
void k_obj_core_unlink(struct k_obj_core *obj_core)
Unlink the kernel object from the kernel object type list.
void k_obj_core_init_and_link(struct k_obj_core *obj_core, struct k_obj_type *type)
Automatically link the kernel object after initializing it.
void k_obj_core_init(struct k_obj_core *obj_core, struct k_obj_type *type)
Initialize the core of the kernel object.
int k_obj_core_stats_enable(struct k_obj_core *obj_core)
Reset the stats associated with the kernel object.
int k_obj_core_stats_reset(struct k_obj_core *obj_core)
Reset the stats associated with the kernel object.
int k_obj_core_stats_query(struct k_obj_core *obj_core, void *stats, size_t stats_len)
Retrieve the statistics associated with the kernel object.
int k_obj_core_stats_disable(struct k_obj_core *obj_core)
Stop gathering the stats associated with the kernel object.
int k_obj_core_stats_raw(struct k_obj_core *obj_core, void *stats, size_t stats_len)
Retrieve the raw statistics associated with the kernel object.
int k_obj_core_stats_deregister(struct k_obj_core *obj_core)
Deregister kernel object from gathering statistics.
int k_obj_core_stats_register(struct k_obj_core *obj_core, void *stats, size_t stats_len)
Register kernel object for gathering statistics.
struct _slist sys_slist_t
Single-linked list structure.
Definition slist.h:49
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
#define NULL
Definition iar_missing_defs.h:20
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Object core statistics descriptor.
Definition obj_core.h:97
int(* raw)(struct k_obj_core *obj_core, void *stats)
Function pointer to retrieve internal representation of stats.
Definition obj_core.h:102
int(* reset)(struct k_obj_core *obj_core)
Function pointer to reset object's statistics.
Definition obj_core.h:106
size_t raw_size
Internal representation stats buffer size.
Definition obj_core.h:98
int(* query)(struct k_obj_core *obj_core, void *stats)
Function pointer to retrieve reported statistics.
Definition obj_core.h:104
size_t query_size
Stats buffer size used for reporting.
Definition obj_core.h:99
int(* enable)(struct k_obj_core *obj_core)
Function pointer to enable object's statistics gathering.
Definition obj_core.h:110
int(* disable)(struct k_obj_core *obj_core)
Function pointer to disable object's statistics gathering.
Definition obj_core.h:108
Object core structure.
Definition obj_core.h:126
sys_snode_t node
Object node within object type's list.
Definition obj_core.h:127
struct k_obj_type * type
Object type to which object belongs.
Definition obj_core.h:128
Object type structure.
Definition obj_core.h:114
size_t obj_core_offset
Offset to obj_core field.
Definition obj_core.h:118
sys_snode_t node
Node within list of object types.
Definition obj_core.h:115
sys_slist_t list
List of objects of this object type.
Definition obj_core.h:116
uint32_t id
Unique type ID.
Definition obj_core.h:117