32struct rt_custom_object
34 struct rt_object parent;
45#ifdef RT_USING_SEMAPHORE
54#ifdef RT_USING_MAILBOX
57#ifdef RT_USING_MESSAGEQUEUE
60#ifdef RT_USING_MEMHEAP
61 RT_Object_Info_MemHeap,
63#ifdef RT_USING_MEMPOOL
77 RT_Object_Info_Channel,
78 RT_Object_Info_ProcessGroup,
79 RT_Object_Info_Session,
87#define _OBJ_CONTAINER_LIST_INIT(c) \
88 {&(_object_container[c].object_list), &(_object_container[c].object_list)}
94#ifdef RT_USING_SEMAPHORE
106#ifdef RT_USING_MAILBOX
110#ifdef RT_USING_MESSAGEQUEUE
114#ifdef RT_USING_MEMHEAP
118#ifdef RT_USING_MEMPOOL
122#ifdef RT_USING_DEVICE
128#ifdef RT_USING_MODULE
147#if defined(RT_USING_HOOK) && defined(RT_HOOK_USING_FUNC_PTR)
148static void (*rt_object_attach_hook)(
struct rt_object *object);
149static void (*rt_object_detach_hook)(
struct rt_object *object);
150void (*rt_object_trytake_hook)(
struct rt_object *object);
151void (*rt_object_take_hook)(
struct rt_object *object);
152void (*rt_object_put_hook)(
struct rt_object *object);
168 rt_object_attach_hook = hook;
179 rt_object_detach_hook = hook;
197 rt_object_trytake_hook = hook;
216 rt_object_take_hook = hook;
227 rt_object_put_hook = hook;
255 if (_object_container[index].type == type)
return &_object_container[index];
277 if (information ==
RT_NULL)
return 0;
312 if (maxlen <= 0)
return 0;
315 if (information ==
RT_NULL)
return 0;
323 pointers[index] = object;
326 if (index >= maxlen)
break;
349#ifdef RT_DEBUGING_ASSERT
353#ifdef RT_USING_MODULE
354 struct rt_dlmodule *module = dlmodule_self();
361#ifdef RT_DEBUGING_ASSERT
384 rt_strncpy(object->
name, name, RT_NAME_MAX);
393#ifdef RT_USING_MODULE
397 object->module_id = (
void *)module;
450#ifdef RT_USING_MODULE
451 struct rt_dlmodule *module = dlmodule_self();
479 rt_strncpy(object->
name, name, RT_NAME_MAX - 1);
488#ifdef RT_USING_MODULE
492 object->module_id = (
void *)module;
615 if ((error = iter(
object, data)) != RT_EOK)
619 return error >= 0 ? RT_EOK : error;
628struct _obj_find_param
630 const char *match_name;
634static rt_err_t _match_name(
struct rt_object *obj,
void *data)
636 struct _obj_find_param *param = data;
637 const char *name = param->match_name;
638 if (rt_strncmp(obj->
name, name, RT_NAME_MAX) == 0)
640 param->matched_obj = obj;
664 struct _obj_find_param param =
677 return param.matched_obj;
694 if ((
object !=
RT_NULL) && (name !=
RT_NULL) && (name_size != 0U))
696 const char *obj_name =
object->name;
697 (void) rt_strncpy(name, obj_name, (
rt_size_t)name_size);
721 struct rt_custom_object *cobj =
RT_NULL;
728 cobj->destroy = data_destroy;
745 struct rt_custom_object *cobj = (
struct rt_custom_object *)obj;
751 ret = cobj->destroy(cobj->data);
rt_base_t rt_spin_lock_irqsave(struct rt_spinlock *lock)
This function will disable the local interrupt and then lock the spinlock, will lock the thread sched...
void rt_spin_unlock_irqrestore(struct rt_spinlock *lock, rt_base_t level)
This function will unlock the spinlock and then restore current cpu interrupt status,...
void rt_object_delete(rt_object_t object)
This function will delete an object and release object memory.
void rt_object_init(struct rt_object *object, enum rt_object_class_type type, const char *name)
This function will initialize an object and add it to object system management.
rt_bool_t rt_object_is_systemobject(rt_object_t object)
This function will judge the object is system object or not.
void rt_object_detach_sethook(void(*hook)(struct rt_object *object))
#define RT_OBJECT_HOOK_CALL(func, argv)
rt_err_t rt_object_get_name(rt_object_t object, char *name, rt_uint8_t name_size)
This function will return the name of the specified object container
rt_err_t rt_custom_object_destroy(rt_object_t obj)
rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name)
This function will allocate an object from object system.
void rt_object_take_sethook(void(*hook)(struct rt_object *object))
rt_object_t rt_object_find(const char *name, rt_uint8_t type)
This function will find specified name object from object container.
rt_object_t rt_custom_object_create(const char *name, void *data, rt_err_t(*data_destroy)(void *))
void rt_object_attach_sethook(void(*hook)(struct rt_object *object))
struct rt_object_information * rt_object_get_information(enum rt_object_class_type type)
This function will return the specified type of object information.
rt_uint8_t rt_object_get_type(rt_object_t object)
This function will return the type of object without RT_Object_Class_Static flag.
struct rt_object * rt_object_t
int rt_object_get_length(enum rt_object_class_type type)
This function will return the length of object list in object container.
rt_err_t rt_object_for_each(rt_uint8_t type, rt_object_iter_t iter, void *data)
This function will iterate through each object from object container.
int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen)
This function will copy the object pointer of the specified type, with the maximum size specified by ...
void rt_object_trytake_sethook(void(*hook)(struct rt_object *object))
rt_err_t(* rt_object_iter_t)(rt_object_t object, void *data)
void rt_object_put_sethook(void(*hook)(struct rt_object *object))
void rt_object_detach(rt_object_t object)
This function will detach a static object from object system, and the memory of static object is not ...
@ RT_Object_Class_MemHeap
@ RT_Object_Class_MessageQueue
@ RT_Object_Class_ProcessGroup
@ RT_Object_Class_MemPool
@ RT_Object_Class_MailBox
@ RT_Object_Class_Channel
@ RT_Object_Class_Semaphore
@ RT_Object_Class_Session
rt_inline void rt_list_remove(rt_list_t *n)
remove node from list.
#define rt_list_for_each(pos, head)
#define rt_list_entry(node, type, member)
get the struct for this entry
#define RT_DEBUG_NOT_IN_INTERRUPT
rt_inline void rt_list_insert_after(rt_list_t *l, rt_list_t *n)
insert a node after a list
#define _OBJ_CONTAINER_LIST_INIT(c)
@ RT_Object_Info_MessageQueue
@ RT_Object_Info_Semaphore
#define RT_KERNEL_FREE(ptr)
#define RT_KERNEL_MALLOC(sz)
#define RTM_EXPORT(symbol)
struct rt_list_node * next