Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Object Core APIs

Data Structures

struct  k_obj_core_stats_desc
 Object core statistics descriptor. More...
 
struct  k_obj_type
 Object type structure. More...
 
struct  k_obj_core
 Object core structure. More...
 

Macros

#define K_OBJ_CORE(kobj)   (&((kobj)->obj_core))
 Convert kernel object pointer into its object core pointer.
 
#define K_OBJ_TYPE_ID_GEN(s)   ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | (s[3]))
 Generate new object type IDs based on a 4 letter string.
 
#define K_OBJ_TYPE_CONDVAR_ID   K_OBJ_TYPE_ID_GEN("COND")
 Condition variable object type.
 
#define K_OBJ_TYPE_CPU_ID   K_OBJ_TYPE_ID_GEN("CPU_")
 CPU object type.
 
#define K_OBJ_TYPE_EVENT_ID   K_OBJ_TYPE_ID_GEN("EVNT")
 Event object type.
 
#define K_OBJ_TYPE_FIFO_ID   K_OBJ_TYPE_ID_GEN("FIFO")
 FIFO object type.
 
#define K_OBJ_TYPE_KERNEL_ID   K_OBJ_TYPE_ID_GEN("KRNL")
 Kernel object type.
 
#define K_OBJ_TYPE_LIFO_ID   K_OBJ_TYPE_ID_GEN("LIFO")
 LIFO object type.
 
#define K_OBJ_TYPE_MEM_BLOCK_ID   K_OBJ_TYPE_ID_GEN("MBLK")
 Memory block object type.
 
#define K_OBJ_TYPE_MBOX_ID   K_OBJ_TYPE_ID_GEN("MBOX")
 Mailbox object type.
 
#define K_OBJ_TYPE_MEM_SLAB_ID   K_OBJ_TYPE_ID_GEN("SLAB")
 Memory slab object type.
 
#define K_OBJ_TYPE_MSGQ_ID   K_OBJ_TYPE_ID_GEN("MSGQ")
 Message queue object type.
 
#define K_OBJ_TYPE_MUTEX_ID   K_OBJ_TYPE_ID_GEN("MUTX")
 Mutex object type.
 
#define K_OBJ_TYPE_PIPE_ID   K_OBJ_TYPE_ID_GEN("PIPE")
 Pipe object type.
 
#define K_OBJ_TYPE_SEM_ID   K_OBJ_TYPE_ID_GEN("SEM4")
 Semaphore object type.
 
#define K_OBJ_TYPE_STACK_ID   K_OBJ_TYPE_ID_GEN("STCK")
 Stack object type.
 
#define K_OBJ_TYPE_THREAD_ID   K_OBJ_TYPE_ID_GEN("THRD")
 Thread object type.
 
#define K_OBJ_TYPE_TIMER_ID   K_OBJ_TYPE_ID_GEN("TIMR")
 Timer object type.
 

Functions

struct k_obj_typek_obj_type_find (uint32_t type_id)
 Find a specific object type by ID.
 
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.
 
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_init (struct k_obj_core *obj_core, struct k_obj_type *type)
 Initialize the core of the kernel object.
 
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_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_unlink (struct k_obj_core *obj_core)
 Unlink the kernel object from the kernel object type list.
 

Detailed Description

Macro Definition Documentation

◆ K_OBJ_CORE

#define K_OBJ_CORE (   kobj)    (&((kobj)->obj_core))

#include <include/zephyr/kernel/obj_core.h>

Convert kernel object pointer into its object core pointer.

◆ K_OBJ_TYPE_CONDVAR_ID

#define K_OBJ_TYPE_CONDVAR_ID   K_OBJ_TYPE_ID_GEN("COND")

#include <include/zephyr/kernel/obj_core.h>

Condition variable object type.

◆ K_OBJ_TYPE_CPU_ID

#define K_OBJ_TYPE_CPU_ID   K_OBJ_TYPE_ID_GEN("CPU_")

#include <include/zephyr/kernel/obj_core.h>

CPU object type.

◆ K_OBJ_TYPE_EVENT_ID

#define K_OBJ_TYPE_EVENT_ID   K_OBJ_TYPE_ID_GEN("EVNT")

#include <include/zephyr/kernel/obj_core.h>

Event object type.

◆ K_OBJ_TYPE_FIFO_ID

#define K_OBJ_TYPE_FIFO_ID   K_OBJ_TYPE_ID_GEN("FIFO")

#include <include/zephyr/kernel/obj_core.h>

FIFO object type.

◆ K_OBJ_TYPE_ID_GEN

#define K_OBJ_TYPE_ID_GEN (   s)    ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | (s[3]))

#include <include/zephyr/kernel/obj_core.h>

Generate new object type IDs based on a 4 letter string.

◆ K_OBJ_TYPE_KERNEL_ID

#define K_OBJ_TYPE_KERNEL_ID   K_OBJ_TYPE_ID_GEN("KRNL")

#include <include/zephyr/kernel/obj_core.h>

Kernel object type.

◆ K_OBJ_TYPE_LIFO_ID

#define K_OBJ_TYPE_LIFO_ID   K_OBJ_TYPE_ID_GEN("LIFO")

#include <include/zephyr/kernel/obj_core.h>

LIFO object type.

◆ K_OBJ_TYPE_MBOX_ID

#define K_OBJ_TYPE_MBOX_ID   K_OBJ_TYPE_ID_GEN("MBOX")

#include <include/zephyr/kernel/obj_core.h>

Mailbox object type.

◆ K_OBJ_TYPE_MEM_BLOCK_ID

#define K_OBJ_TYPE_MEM_BLOCK_ID   K_OBJ_TYPE_ID_GEN("MBLK")

#include <include/zephyr/kernel/obj_core.h>

Memory block object type.

◆ K_OBJ_TYPE_MEM_SLAB_ID

#define K_OBJ_TYPE_MEM_SLAB_ID   K_OBJ_TYPE_ID_GEN("SLAB")

#include <include/zephyr/kernel/obj_core.h>

Memory slab object type.

◆ K_OBJ_TYPE_MSGQ_ID

#define K_OBJ_TYPE_MSGQ_ID   K_OBJ_TYPE_ID_GEN("MSGQ")

#include <include/zephyr/kernel/obj_core.h>

Message queue object type.

◆ K_OBJ_TYPE_MUTEX_ID

#define K_OBJ_TYPE_MUTEX_ID   K_OBJ_TYPE_ID_GEN("MUTX")

#include <include/zephyr/kernel/obj_core.h>

Mutex object type.

◆ K_OBJ_TYPE_PIPE_ID

#define K_OBJ_TYPE_PIPE_ID   K_OBJ_TYPE_ID_GEN("PIPE")

#include <include/zephyr/kernel/obj_core.h>

Pipe object type.

◆ K_OBJ_TYPE_SEM_ID

#define K_OBJ_TYPE_SEM_ID   K_OBJ_TYPE_ID_GEN("SEM4")

#include <include/zephyr/kernel/obj_core.h>

Semaphore object type.

◆ K_OBJ_TYPE_STACK_ID

#define K_OBJ_TYPE_STACK_ID   K_OBJ_TYPE_ID_GEN("STCK")

#include <include/zephyr/kernel/obj_core.h>

Stack object type.

◆ K_OBJ_TYPE_THREAD_ID

#define K_OBJ_TYPE_THREAD_ID   K_OBJ_TYPE_ID_GEN("THRD")

#include <include/zephyr/kernel/obj_core.h>

Thread object type.

◆ K_OBJ_TYPE_TIMER_ID

#define K_OBJ_TYPE_TIMER_ID   K_OBJ_TYPE_ID_GEN("TIMR")

#include <include/zephyr/kernel/obj_core.h>

Timer object type.

Function Documentation

◆ k_obj_core_init()

void k_obj_core_init ( struct k_obj_core obj_core,
struct k_obj_type type 
)

#include <include/zephyr/kernel/obj_core.h>

Initialize the core of the kernel object.

Initializing the kernel object core associates it with the specified kernel object type.

Parameters
obj_corePointer to the kernel object to initialize
typePointer to the kernel object type

◆ k_obj_core_init_and_link()

void k_obj_core_init_and_link ( struct k_obj_core obj_core,
struct k_obj_type type 
)

#include <include/zephyr/kernel/obj_core.h>

Automatically link the kernel object after initializing it.

A useful wrapper to both initialize the core of the kernel object and automatically link it into the kernel object type's list of objects.

Parameters
obj_corePointer to the kernel object to initialize
typePointer to the kernel object type

◆ k_obj_core_link()

void k_obj_core_link ( struct k_obj_core obj_core)

#include <include/zephyr/kernel/obj_core.h>

Link the kernel object to the kernel object type list.

A kernel object can be optionally linked into the kernel object type's list of objects. A kernel object must have been initialized before it can be linked. Linked kernel objects can be traversed and have information extracted from them by system tools.

Parameters
obj_corePointer to the kernel object

◆ k_obj_core_unlink()

void k_obj_core_unlink ( struct k_obj_core obj_core)

#include <include/zephyr/kernel/obj_core.h>

Unlink the kernel object from the kernel object type list.

Kernel objects can be unlinked from their respective kernel object type lists. If on a list, it must be done at the end of the kernel object's life cycle.

Parameters
obj_corePointer to the kernel object

◆ k_obj_type_find()

struct k_obj_type * k_obj_type_find ( uint32_t  type_id)

#include <include/zephyr/kernel/obj_core.h>

Find a specific object type by ID.

Given an object type ID, this function searches for the object type that is associated with the specified type ID type_id.

Parameters
type_idType ID associated with object type
Return values
NULLif object type not found
Pointerto object type if found

◆ k_obj_type_walk_locked()

int k_obj_type_walk_locked ( struct k_obj_type type,
int(*)(struct k_obj_core *, void *)  func,
void *  data 
)

#include <include/zephyr/kernel/obj_core.h>

Walk the object type's list of object cores.

This function takes a global spinlock and walks the object type's list of object cores and invokes the callback function on each element while holding that lock. Although this will ensure that the list is not modified, one can expect a significant penalty in terms of performance and latency.

The callback function shall either return non-zero to stop further walking, or it shall return 0 to continue walking.

Parameters
typePointer to the object type
funcCallback to invoke on each object core of the object type
dataCustom data passed to the callback
Return values
non-zeroif walk is terminated by the callback; otherwise 0

◆ k_obj_type_walk_unlocked()

int k_obj_type_walk_unlocked ( struct k_obj_type type,
int(*)(struct k_obj_core *, void *)  func,
void *  data 
)

#include <include/zephyr/kernel/obj_core.h>

Walk the object type's list of object cores.

This function is similar to k_obj_type_walk_locked() except that it walks the list without obtaining the global spinlock. No synchronization is provided here. Mutation of the list of objects while this function is in progress must be prevented at the application layer, otherwise undefined/unreliable behavior, corruption and/or crashes may result.

The callback function shall either return non-zero to stop further walking, or it shall return 0 to continue walking.

Parameters
typePointer to the object type
funcCallback to invoke on each object core of the object type
dataCustom data passed to the callback
Return values
non-zeroif walk is terminated by the callback; otherwise 0