RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
Kernel Object Management
+ Kernel Object Management 的协作图:

结构体

struct  rt_object
 
struct  rt_object_information
 

宏定义

#define RT_OBJECT_FLAG_MODULE   0x80
 
#define _RT_OBJECT_HOOK_CALL(func, argv)
 
#define RT_OBJECT_HOOK_CALL(func, argv)
 
#define __ON_HOOK_ARGS(__hook, argv)
 
#define RT_OBJECT_HOOKLIST_DECLARE(handler_type, name)
 
#define RT_OBJECT_HOOKLIST_DEFINE_NODE(hookname, nodename, hooker_handler)
 
#define RT_OBJECT_HOOKLIST_DEFINE(name)
 
#define RT_OBJECT_HOOKLIST_CALL(name, argv)
 

类型定义

typedef struct rt_objectrt_object_t
 
typedef rt_err_t(* rt_object_iter_t) (rt_object_t object, void *data)
 

枚举

enum  rt_object_class_type {
  RT_Object_Class_Null = 0x00 , RT_Object_Class_Thread = 0x01 , RT_Object_Class_Semaphore = 0x02 , RT_Object_Class_Mutex = 0x03 ,
  RT_Object_Class_Event = 0x04 , RT_Object_Class_MailBox = 0x05 , RT_Object_Class_MessageQueue = 0x06 , RT_Object_Class_MemHeap = 0x07 ,
  RT_Object_Class_MemPool = 0x08 , RT_Object_Class_Device = 0x09 , RT_Object_Class_Timer = 0x0a , RT_Object_Class_Module = 0x0b ,
  RT_Object_Class_Memory = 0x0c , RT_Object_Class_Channel = 0x0d , RT_Object_Class_ProcessGroup = 0x0e , RT_Object_Class_Session = 0x0f ,
  RT_Object_Class_Custom = 0x10 , RT_Object_Class_Unknown = 0x11 , RT_Object_Class_Static = 0x80
}
 

函数

struct rt_object_informationrt_object_get_information (enum rt_object_class_type type)
 
 RTM_EXPORT (rt_object_get_information)
 
int rt_object_get_length (enum rt_object_class_type type)
 
 RTM_EXPORT (rt_object_get_length)
 
int rt_object_get_pointers (enum rt_object_class_type type, rt_object_t *pointers, int maxlen)
 
 RTM_EXPORT (rt_object_get_pointers)
 
void rt_object_init (struct rt_object *object, enum rt_object_class_type type, const char *name)
 
void rt_object_detach (rt_object_t object)
 
rt_object_t rt_object_allocate (enum rt_object_class_type type, const char *name)
 
void rt_object_delete (rt_object_t object)
 
rt_bool_t rt_object_is_systemobject (rt_object_t object)
 
rt_uint8_t rt_object_get_type (rt_object_t object)
 
rt_err_t rt_object_for_each (rt_uint8_t type, rt_object_iter_t iter, void *data)
 
rt_object_t rt_object_find (const char *name, rt_uint8_t type)
 
rt_err_t rt_object_get_name (rt_object_t object, char *name, rt_uint8_t name_size)
 
rt_object_t rt_custom_object_create (const char *name, void *data, rt_err_t(*data_destroy)(void *))
 
rt_err_t rt_custom_object_destroy (rt_object_t obj)
 
void rt_object_attach_sethook (void(*hook)(struct rt_object *object))
 
void rt_object_detach_sethook (void(*hook)(struct rt_object *object))
 
void rt_object_trytake_sethook (void(*hook)(struct rt_object *object))
 
void rt_object_take_sethook (void(*hook)(struct rt_object *object))
 
void rt_object_put_sethook (void(*hook)(struct rt_object *object))
 

详细描述

kernel object management

The Kernel object system can access and manage all of the kernel objects.

Kernel objects include most of the facilities in the kernel:

Kernel objects can be static objects, whose memory is allocated in compiling. It can be dynamic objects as well, whose memory is allocated from system heaps in runtime.

宏定义说明

◆ RT_OBJECT_FLAG_MODULE

#define RT_OBJECT_FLAG_MODULE   0x80

is module object.

在文件 rtdef.h275 行定义.

◆ _RT_OBJECT_HOOK_CALL

#define _RT_OBJECT_HOOK_CALL ( func,
argv )
值:
__ON_HOOK_ARGS(func, argv)
#define __ON_HOOK_ARGS(__hook, argv)

Add hook point in the routines

The hook function call macro

注解
Usage: void foo() { do_something();

RT_OBJECT_HOOK_CALL(foo);

do_other_things(); }

在文件 rtdef.h381 行定义.

◆ RT_OBJECT_HOOK_CALL

#define RT_OBJECT_HOOK_CALL ( func,
argv )
值:
#define _RT_OBJECT_HOOK_CALL(func, argv)
Add hook point in the routines

在文件 rtdef.h382 行定义.

◆ __ON_HOOK_ARGS

#define __ON_HOOK_ARGS ( __hook,
argv )

在文件 rtdef.h387 行定义.

◆ RT_OBJECT_HOOKLIST_DECLARE

#define RT_OBJECT_HOOKLIST_DECLARE ( handler_type,
name )

在文件 rtdef.h507 行定义.

◆ RT_OBJECT_HOOKLIST_DEFINE_NODE

#define RT_OBJECT_HOOKLIST_DEFINE_NODE ( hookname,
nodename,
hooker_handler )

在文件 rtdef.h508 行定义.

◆ RT_OBJECT_HOOKLIST_DEFINE

#define RT_OBJECT_HOOKLIST_DEFINE ( name)

在文件 rtdef.h509 行定义.

◆ RT_OBJECT_HOOKLIST_CALL

#define RT_OBJECT_HOOKLIST_CALL ( name,
argv )

在文件 rtdef.h510 行定义.

类型定义说明

◆ rt_object_t

typedef struct rt_object* rt_object_t

Type for kernel objects.

在文件 rtdef.h300 行定义.

◆ rt_object_iter_t

typedef rt_err_t(* rt_object_iter_t) (rt_object_t object, void *data)

iterator of rt_object_for_each()

data is the data passing in to rt_object_for_each(). iterator can return RT_EOK to continue the iteration; or any positive value to break the loop successfully; or any negative errno to break the loop on failure.

在文件 rtdef.h309 行定义.

枚举类型说明

◆ rt_object_class_type

The object type can be one of the follows with specific macros enabled:

  • Thread
  • Semaphore
  • Mutex
  • Event
  • MailBox
  • MessageQueue
  • MemHeap
  • MemPool
  • Device
  • Timer
  • Module
  • Unknown
  • Static
枚举值
RT_Object_Class_Null 0x00 

The object is not used.

RT_Object_Class_Thread 0x01 

The object is a thread.

RT_Object_Class_Semaphore 0x02 

The object is a semaphore.

RT_Object_Class_Mutex 0x03 

The object is a mutex.

RT_Object_Class_Event 0x04 

The object is a event.

RT_Object_Class_MailBox 0x05 

The object is a mail box.

RT_Object_Class_MessageQueue 0x06 

The object is a message queue.

RT_Object_Class_MemHeap 0x07 

The object is a memory heap.

RT_Object_Class_MemPool 0x08 

The object is a memory pool.

RT_Object_Class_Device 0x09 

The object is a device.

RT_Object_Class_Timer 0x0a 

The object is a timer.

RT_Object_Class_Module 0x0b 

The object is a module.

RT_Object_Class_Memory 0x0c 

The object is a memory.

RT_Object_Class_Channel 0x0d 

The object is a channel

RT_Object_Class_ProcessGroup 0x0e 

The object is a process group

RT_Object_Class_Session 0x0f 

The object is a session

RT_Object_Class_Custom 0x10 

The object is a custom object

RT_Object_Class_Unknown 0x11 

The object is unknown.

RT_Object_Class_Static 0x80 

The object is a static object.

在文件 rtdef.h328 行定义.

329{
330 RT_Object_Class_Null = 0x00,
333 RT_Object_Class_Mutex = 0x03,
334 RT_Object_Class_Event = 0x04,
340 RT_Object_Class_Timer = 0x0a,
349};
@ RT_Object_Class_Memory
@ RT_Object_Class_Module
@ RT_Object_Class_MemHeap
@ RT_Object_Class_Timer
@ RT_Object_Class_MessageQueue
@ RT_Object_Class_ProcessGroup
@ RT_Object_Class_MemPool
@ RT_Object_Class_Thread
@ RT_Object_Class_MailBox
@ RT_Object_Class_Unknown
@ RT_Object_Class_Channel
@ RT_Object_Class_Semaphore
@ RT_Object_Class_Null
@ RT_Object_Class_Session
@ RT_Object_Class_Event
@ RT_Object_Class_Static
@ RT_Object_Class_Device
@ RT_Object_Class_Custom
@ RT_Object_Class_Mutex

函数说明

◆ rt_object_get_information()

struct rt_object_information * rt_object_get_information ( enum rt_object_class_type type)

This function will return the specified type of object information.

参数
typeis the type of object, which can be RT_Object_Class_Thread/Semaphore/Mutex... etc
返回
the object type information or RT_NULL

在文件 object.c248 行定义.

249{
250 int index;
251
252 type = (enum rt_object_class_type)(type & ~RT_Object_Class_Static);
253
254 for (index = 0; index < RT_Object_Info_Unknown; index ++)
255 if (_object_container[index].type == type) return &_object_container[index];
256
257 return RT_NULL;
258}
rt_object_class_type
@ RT_Object_Info_Unknown
#define RT_NULL

引用了 RT_NULL, RT_Object_Class_Static , 以及 RT_Object_Info_Unknown.

+ 这是这个函数的调用关系图:

◆ RTM_EXPORT() [1/3]

RTM_EXPORT ( rt_object_get_information )

引用了 rt_object_get_information().

+ 函数调用图:

◆ rt_object_get_length()

int rt_object_get_length ( enum rt_object_class_type type)

This function will return the length of object list in object container.

参数
typeis the type of object, which can be RT_Object_Class_Thread/Semaphore/Mutex... etc
返回
the length of object list

在文件 object.c269 行定义.

270{
271 int count = 0;
272 rt_base_t level;
273 struct rt_list_node *node = RT_NULL;
274 struct rt_object_information *information = RT_NULL;
275
277 if (information == RT_NULL) return 0;
278
279 level = rt_spin_lock_irqsave(&(information->spinlock));
280 rt_list_for_each(node, &(information->object_list))
281 {
282 count ++;
283 }
284 rt_spin_unlock_irqrestore(&(information->spinlock), level);
285
286 return count;
287}
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,...
struct rt_object_information * rt_object_get_information(enum rt_object_class_type type)
This function will return the specified type of object information.
#define rt_list_for_each(pos, head)
rt_int32_t rt_base_t
struct rt_spinlock spinlock
enum rt_object_class_type type

引用了 rt_object_information::object_list, rt_list_for_each, RT_NULL, rt_object_get_information(), rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore() , 以及 rt_object_information::spinlock.

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ RTM_EXPORT() [2/3]

RTM_EXPORT ( rt_object_get_length )

引用了 rt_object_get_length().

+ 函数调用图:

◆ rt_object_get_pointers()

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 maxlen.

参数
typeis the type of object, which can be RT_Object_Class_Thread/Semaphore/Mutex... etc
pointersis the pointer will be saved to.
maxlenis the maximum number of pointers can be saved.
返回
the copied number of object pointers.

在文件 object.c303 行定义.

304{
305 int index = 0;
306 rt_base_t level;
307
308 struct rt_object *object;
309 struct rt_list_node *node = RT_NULL;
310 struct rt_object_information *information = RT_NULL;
311
312 if (maxlen <= 0) return 0;
313
314 information = rt_object_get_information(type);
315 if (information == RT_NULL) return 0;
316
317 level = rt_spin_lock_irqsave(&(information->spinlock));
318 /* retrieve pointer of object */
319 rt_list_for_each(node, &(information->object_list))
320 {
321 object = rt_list_entry(node, struct rt_object, list);
322
323 pointers[index] = object;
324 index ++;
325
326 if (index >= maxlen) break;
327 }
328 rt_spin_unlock_irqrestore(&(information->spinlock), level);
329
330 return index;
331}
#define rt_list_entry(node, type, member)
get the struct for this entry

引用了 rt_object_information::object_list, rt_list_entry, rt_list_for_each, RT_NULL, rt_object_get_information(), rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore() , 以及 rt_object_information::spinlock.

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ RTM_EXPORT() [3/3]

RTM_EXPORT ( rt_object_get_pointers )

引用了 rt_object_get_pointers().

+ 函数调用图:

◆ rt_object_init()

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.

参数
objectis the specified object to be initialized.
typeis the object type.
nameis the object name. In system, the object's name must be unique.

在文件 object.c344 行定义.

347{
348 rt_base_t level;
349#ifdef RT_DEBUGING_ASSERT
350 struct rt_list_node *node = RT_NULL;
351#endif /* RT_DEBUGING_ASSERT */
352 struct rt_object_information *information;
353#ifdef RT_USING_MODULE
354 struct rt_dlmodule *module = dlmodule_self();
355#endif /* RT_USING_MODULE */
356
357 /* get object information */
358 information = rt_object_get_information(type);
359 RT_ASSERT(information != RT_NULL);
360
361#ifdef RT_DEBUGING_ASSERT
362 /* check object type to avoid re-initialization */
363
364 /* enter critical */
365 level = rt_spin_lock_irqsave(&(information->spinlock));
366 /* try to find object */
367 for (node = information->object_list.next;
368 node != &(information->object_list);
369 node = node->next)
370 {
371 struct rt_object *obj;
372
373 obj = rt_list_entry(node, struct rt_object, list);
374 RT_ASSERT(obj != object);
375 }
376 /* leave critical */
377 rt_spin_unlock_irqrestore(&(information->spinlock), level);
378#endif /* RT_DEBUGING_ASSERT */
379
380 /* initialize object's parameters */
381 /* set object type to static */
382 object->type = type | RT_Object_Class_Static;
383#if RT_NAME_MAX > 0
384 rt_strncpy(object->name, name, RT_NAME_MAX); /* copy name */
385#else
386 object->name = name;
387#endif /* RT_NAME_MAX > 0 */
388
389 RT_OBJECT_HOOK_CALL(rt_object_attach_hook, (object));
390
391 level = rt_spin_lock_irqsave(&(information->spinlock));
392
393#ifdef RT_USING_MODULE
394 if (module)
395 {
396 rt_list_insert_after(&(module->object_list), &(object->list));
397 object->module_id = (void *)module;
398 }
399 else
400#endif /* RT_USING_MODULE */
401 {
402 /* insert object into information object list */
403 rt_list_insert_after(&(information->object_list), &(object->list));
404 }
405 rt_spin_unlock_irqrestore(&(information->spinlock), level);
406}
#define RT_OBJECT_HOOK_CALL(func, argv)
#define RT_ASSERT(EX)
rt_inline void rt_list_insert_after(rt_list_t *l, rt_list_t *n)
insert a node after a list
struct rt_list_node * next
rt_list_t list
rt_uint8_t type
const char * name

引用了 rt_object::list, rt_object::name, rt_list_node::next, rt_object_information::object_list, RT_ASSERT, rt_list_entry, rt_list_insert_after(), RT_NULL, RT_Object_Class_Static, rt_object_get_information(), RT_OBJECT_HOOK_CALL, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore() , 以及 rt_object_information::spinlock.

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ rt_object_detach()

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 freed.

参数
objectthe specified object to be detached.

在文件 object.c414 行定义.

415{
416 rt_base_t level;
417 struct rt_object_information *information;
418
419 /* object check */
420 RT_ASSERT(object != RT_NULL);
421
422 RT_OBJECT_HOOK_CALL(rt_object_detach_hook, (object));
423
424 information = rt_object_get_information((enum rt_object_class_type)object->type);
425 RT_ASSERT(information != RT_NULL);
426
427 level = rt_spin_lock_irqsave(&(information->spinlock));
428 /* remove from old list */
429 rt_list_remove(&(object->list));
430 rt_spin_unlock_irqrestore(&(information->spinlock), level);
431
432 object->type = RT_Object_Class_Null;
433}
rt_inline void rt_list_remove(rt_list_t *n)
remove node from list.

引用了 rt_object::list, RT_ASSERT, rt_list_remove(), RT_NULL, RT_Object_Class_Null, rt_object_get_information(), RT_OBJECT_HOOK_CALL, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), rt_object_information::spinlock , 以及 rt_object::type.

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ rt_object_allocate()

rt_object_t rt_object_allocate ( enum rt_object_class_type type,
const char * name )

This function will allocate an object from object system.

参数
typeis the type of object.
nameis the object name. In system, the object's name must be unique.
返回
object

在文件 object.c445 行定义.

446{
447 struct rt_object *object;
448 rt_base_t level;
449 struct rt_object_information *information;
450#ifdef RT_USING_MODULE
451 struct rt_dlmodule *module = dlmodule_self();
452#endif /* RT_USING_MODULE */
453
455
456 /* get object information */
457 information = rt_object_get_information(type);
458 RT_ASSERT(information != RT_NULL);
459
460 object = (struct rt_object *)RT_KERNEL_MALLOC(information->object_size);
461 if (object == RT_NULL)
462 {
463 /* no memory can be allocated */
464 return RT_NULL;
465 }
466
467 /* clean memory data of object */
468 rt_memset(object, 0x0, information->object_size);
469
470 /* initialize object's parameters */
471
472 /* set object type */
473 object->type = type;
474
475 /* set object flag */
476 object->flag = 0;
477
478#if RT_NAME_MAX > 0
479 rt_strncpy(object->name, name, RT_NAME_MAX - 1); /* copy name */
480#else
481 object->name = name;
482#endif /* RT_NAME_MAX > 0 */
483
484 RT_OBJECT_HOOK_CALL(rt_object_attach_hook, (object));
485
486 level = rt_spin_lock_irqsave(&(information->spinlock));
487
488#ifdef RT_USING_MODULE
489 if (module)
490 {
491 rt_list_insert_after(&(module->object_list), &(object->list));
492 object->module_id = (void *)module;
493 }
494 else
495#endif /* RT_USING_MODULE */
496 {
497 /* insert object into information object list */
498 rt_list_insert_after(&(information->object_list), &(object->list));
499 }
500 rt_spin_unlock_irqrestore(&(information->spinlock), level);
501
502 return object;
503}
#define RT_DEBUG_NOT_IN_INTERRUPT
#define RT_KERNEL_MALLOC(sz)

引用了 rt_object::list, rt_object::name, rt_object_information::object_list, rt_object_information::object_size, RT_ASSERT, RT_DEBUG_NOT_IN_INTERRUPT, RT_KERNEL_MALLOC, rt_list_insert_after(), RT_NULL, rt_object_get_information(), RT_OBJECT_HOOK_CALL, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore() , 以及 rt_object_information::spinlock.

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ rt_object_delete()

void rt_object_delete ( rt_object_t object)

This function will delete an object and release object memory.

参数
objectis the specified object to be deleted.

在文件 object.c510 行定义.

511{
512 rt_base_t level;
513 struct rt_object_information *information;
514
515 /* object check */
516 RT_ASSERT(object != RT_NULL);
518
519 RT_OBJECT_HOOK_CALL(rt_object_detach_hook, (object));
520
521
522 information = rt_object_get_information((enum rt_object_class_type)object->type);
523 RT_ASSERT(information != RT_NULL);
524
525 level = rt_spin_lock_irqsave(&(information->spinlock));
526
527 /* remove from old list */
528 rt_list_remove(&(object->list));
529
530 rt_spin_unlock_irqrestore(&(information->spinlock), level);
531
532 /* reset object type */
533 object->type = RT_Object_Class_Null;
534
535 /* free the memory of object */
536 RT_KERNEL_FREE(object);
537}
#define RT_KERNEL_FREE(ptr)

引用了 rt_object::list, RT_ASSERT, RT_KERNEL_FREE, rt_list_remove(), RT_NULL, RT_Object_Class_Null, RT_Object_Class_Static, rt_object_get_information(), RT_OBJECT_HOOK_CALL, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore(), rt_object_information::spinlock , 以及 rt_object::type.

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ rt_object_is_systemobject()

rt_bool_t rt_object_is_systemobject ( rt_object_t object)

This function will judge the object is system object or not.

注解
Normally, the system object is a static object and the type of object set to RT_Object_Class_Static.
参数
objectis the specified object to be judged.
返回
RT_TRUE if a system object, RT_FALSE for others.

在文件 object.c550 行定义.

551{
552 /* object check */
553 RT_ASSERT(object != RT_NULL);
554
555 if (object->type & RT_Object_Class_Static)
556 return RT_TRUE;
557
558 return RT_FALSE;
559}
#define RT_TRUE
#define RT_FALSE

引用了 RT_ASSERT, RT_FALSE, RT_NULL, RT_Object_Class_Static, RT_TRUE , 以及 rt_object::type.

◆ rt_object_get_type()

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.

参数
objectis the specified object to be get type.
返回
the type of object.

在文件 object.c569 行定义.

570{
571 /* object check */
572 RT_ASSERT(object != RT_NULL);
573
574 return object->type & ~RT_Object_Class_Static;
575}

引用了 RT_ASSERT, RT_NULL , 以及 RT_Object_Class_Static.

◆ rt_object_for_each()

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.

参数
typeis the type of object
iteris the iterator
datais the specified data passed to iterator
返回
RT_EOK on succeed, otherwise the error from iter
注解
this function shall not be invoked in interrupt status.

在文件 object.c589 行定义.

590{
591 struct rt_object *object = RT_NULL;
592 struct rt_list_node *node = RT_NULL;
593 struct rt_object_information *information = RT_NULL;
594 rt_base_t level;
595 rt_err_t error;
596
598
599 /* parameter check */
600 if (information == RT_NULL)
601 {
602 return -RT_EINVAL;
603 }
604
605 /* which is invoke in interrupt status */
607
608 /* enter critical */
609 level = rt_spin_lock_irqsave(&(information->spinlock));
610
611 /* try to find object */
612 rt_list_for_each(node, &(information->object_list))
613 {
614 object = rt_list_entry(node, struct rt_object, list);
615 if ((error = iter(object, data)) != RT_EOK)
616 {
617 rt_spin_unlock_irqrestore(&(information->spinlock), level);
618
619 return error >= 0 ? RT_EOK : error;
620 }
621 }
622
623 rt_spin_unlock_irqrestore(&(information->spinlock), level);
624
625 return RT_EOK;
626}
rt_base_t rt_err_t

引用了 rt_object_information::object_list, RT_DEBUG_NOT_IN_INTERRUPT, rt_list_entry, rt_list_for_each, RT_NULL, rt_object_get_information(), rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore() , 以及 rt_object_information::spinlock.

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ rt_object_find()

rt_object_t rt_object_find ( const char * name,
rt_uint8_t type )

This function will find specified name object from object container.

参数
nameis the specified name of object.
typeis the type of object
返回
the found object or RT_NULL if there is no this object in object container.
注解
this function shall not be invoked in interrupt status.

在文件 object.c662 行定义.

663{
664 struct _obj_find_param param =
665 {
666 .match_name = name,
667 .matched_obj = RT_NULL,
668 };
669
670 /* parameter check */
671 if (name == RT_NULL) return RT_NULL;
672
673 /* which is invoke in interrupt status */
675
676 rt_object_for_each(type, _match_name, &param);
677 return param.matched_obj;
678}
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.

引用了 RT_DEBUG_NOT_IN_INTERRUPT, RT_NULL , 以及 rt_object_for_each().

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ rt_object_get_name()

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

参数
objectthe specified object to be get name
namebuffer to store the object name string
name_sizemaximum size of the buffer to store object name
返回
-RT_EINVAL if any parameter is invalid or RT_EOK if the operation is successfully executed
注解
this function shall not be invoked in interrupt status

在文件 object.c691 行定义.

692{
693 rt_err_t result = -RT_EINVAL;
694 if ((object != RT_NULL) && (name != RT_NULL) && (name_size != 0U))
695 {
696 const char *obj_name = object->name;
697 (void) rt_strncpy(name, obj_name, (rt_size_t)name_size);
698 result = RT_EOK;
699 }
700
701 return result;
702}
rt_ubase_t rt_size_t

引用了 RT_NULL.

+ 这是这个函数的调用关系图:

◆ rt_custom_object_create()

rt_object_t rt_custom_object_create ( const char * name,
void * data,
rt_err_t(* data_destroy )(void *) )

This function will create a custom object container.

参数
namethe specified name of object.
datathe custom data
data_destroythe custom object destroy callback
返回
the found object or RT_NULL if there is no this object in object container.
注解
this function shall not be invoked in interrupt status.

在文件 object.c719 行定义.

720{
721 struct rt_custom_object *cobj = RT_NULL;
722
723 cobj = (struct rt_custom_object *)rt_object_allocate(RT_Object_Class_Custom, name);
724 if (!cobj)
725 {
726 return RT_NULL;
727 }
728 cobj->destroy = data_destroy;
729 cobj->data = data;
730 return (struct rt_object *)cobj;
731}
rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name)
This function will allocate an object from object system.

引用了 RT_NULL, rt_object_allocate() , 以及 RT_Object_Class_Custom.

+ 函数调用图:

◆ rt_custom_object_destroy()

rt_err_t rt_custom_object_destroy ( rt_object_t obj)

This function will destroy a custom object container.

参数
objthe specified name of object.
注解
this function shall not be invoked in interrupt status.

在文件 object.c741 行定义.

742{
743 rt_err_t ret = -1;
744
745 struct rt_custom_object *cobj = (struct rt_custom_object *)obj;
746
747 if (obj && obj->type == RT_Object_Class_Custom)
748 {
749 if (cobj->destroy)
750 {
751 ret = cobj->destroy(cobj->data);
752 }
753 rt_object_delete(obj);
754 }
755 return ret;
756}
void rt_object_delete(rt_object_t object)
This function will delete an object and release object memory.

引用了 RT_Object_Class_Custom, rt_object_delete() , 以及 rt_object::type.

+ 函数调用图:

◆ rt_object_attach_sethook()

void rt_object_attach_sethook ( void(* hook )(struct rt_object *object))

◆ rt_object_detach_sethook()

void rt_object_detach_sethook ( void(* hook )(struct rt_object *object))

◆ rt_object_trytake_sethook()

void rt_object_trytake_sethook ( void(* hook )(struct rt_object *object))

◆ rt_object_take_sethook()

void rt_object_take_sethook ( void(* hook )(struct rt_object *object))

◆ rt_object_put_sethook()

void rt_object_put_sethook ( void(* hook )(struct rt_object *object))