Zephyr Project API 3.7.0
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
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
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_LINK(objp) k_obj_core_link(objp)
76#else
77#define K_OBJ_CORE_INIT(objp, type) do { } while (0)
78#define K_OBJ_CORE_LINK(objp) do { } while (0)
79#endif /* CONFIG_OBJ_CORE */
80
89extern sys_slist_t z_obj_type_list;
90
93 size_t raw_size;
94 size_t query_size;
97 int (*raw)(struct k_obj_core *obj_core, void *stats);
99 int (*query)(struct k_obj_core *obj_core, void *stats);
101 int (*reset)(struct k_obj_core *obj_core);
103 int (*disable)(struct k_obj_core *obj_core);
105 int (*enable)(struct k_obj_core *obj_core);
106};
107
114#ifdef CONFIG_OBJ_CORE_STATS
116 struct k_obj_core_stats_desc *stats_desc;
117#endif /* CONFIG_OBJ_CORE_STATS */
118};
119
123 struct k_obj_type *type;
124#ifdef CONFIG_OBJ_CORE_STATS
125 void *stats;
126#endif /* CONFIG_OBJ_CORE_STATS */
127};
128
141struct k_obj_type *z_obj_type_init(struct k_obj_type *type,
142 uint32_t id, size_t off);
143
156
175 int (*func)(struct k_obj_core *, void *),
176 void *data);
177
197 int (*func)(struct k_obj_core *, void *),
198 void *data);
199
209void k_obj_core_init(struct k_obj_core *obj_core, struct k_obj_type *type);
210
221void k_obj_core_link(struct k_obj_core *obj_core);
222
233 struct k_obj_type *type);
234
244void k_obj_core_unlink(struct k_obj_core *obj_core);
245
254#ifdef CONFIG_OBJ_CORE_STATS
263static inline void k_obj_type_stats_init(struct k_obj_type *type,
264 struct k_obj_core_stats_desc *stats_desc)
265{
266 type->stats_desc = stats_desc;
267}
268
278static inline void k_obj_core_stats_init(struct k_obj_core *obj_core,
279 void *stats)
280{
281 obj_core->stats = stats;
282}
283#endif /* CONFIG_OBJ_CORE_STATS */
284
299int k_obj_core_stats_register(struct k_obj_core *obj_core, void *stats,
300 size_t stats_len);
301
315
331int k_obj_core_stats_raw(struct k_obj_core *obj_core, void *stats,
332 size_t stats_len);
333
350int k_obj_core_stats_query(struct k_obj_core *obj_core, void *stats,
351 size_t stats_len);
352
364int k_obj_core_stats_reset(struct k_obj_core *obj_core);
365
379
392
394#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
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Object core statistics descriptor.
Definition obj_core.h:92
int(* raw)(struct k_obj_core *obj_core, void *stats)
Function pointer to retrieve internal representation of stats.
Definition obj_core.h:97
int(* reset)(struct k_obj_core *obj_core)
Function pointer to reset object's statistics.
Definition obj_core.h:101
size_t raw_size
Internal representation stats buffer size.
Definition obj_core.h:93
int(* query)(struct k_obj_core *obj_core, void *stats)
Function pointer to retrieve reported statistics.
Definition obj_core.h:99
size_t query_size
Stats buffer size used for reporting.
Definition obj_core.h:94
int(* enable)(struct k_obj_core *obj_core)
Function pointer to enable object's statistics gathering.
Definition obj_core.h:105
int(* disable)(struct k_obj_core *obj_core)
Function pointer to disable object's statistics gathering.
Definition obj_core.h:103
Object core structure.
Definition obj_core.h:121
sys_snode_t node
Object node within object type's list.
Definition obj_core.h:122
struct k_obj_type * type
Object type to which object belongs.
Definition obj_core.h:123
Object type structure.
Definition obj_core.h:109
size_t obj_core_offset
Offset to obj_core field.
Definition obj_core.h:113
sys_snode_t node
Node within list of object types.
Definition obj_core.h:110
sys_slist_t list
List of objects of this object type.
Definition obj_core.h:111
uint32_t id
Unique type ID.
Definition obj_core.h:112
static fdata_t data[2]
Definition test_fifo_contexts.c:15
static void func(void *arg1, void *arg2, void *arg3)
Definition main.c:26