Skip to content

Commit 5a42cfd

Browse files
unicornxRbb666
authored andcommitted
doxygen: update doc for kenrel object model
Move the introduction of function parameters in markdown to source code comments, because this part of the content is completely repeated. We only need to keep and maintain the comments in the code. The detailed explanation of the API in markdown can directly refer to the comments in the code. Try not to directly copy the definition of the structure in the markdown document, because this part of the content may change with the upgrade of the code. Therefore, when the structure definition is involved in markdown, try to indicate that it is just a code snippet. The specific definition is still directly quoted from the source code and the source code comments. It is very convenient to quote structures and functions in markdown. Just use "`" to enclose the structure name or function name, and the generated html is a link to its definition. According to this principle, this patch only modifies the documents and code comments of the kernel object model. Other modules will be modified one by one in separate patches later. Signed-off-by: Chen Wang <[email protected]>
1 parent 5a09694 commit 5a42cfd

File tree

2 files changed

+40
-71
lines changed

2 files changed

+40
-71
lines changed

documentation/3.kernel/basic/basic.md

+15-61
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ Derivations from object control block rt_object in the above figure includes: th
404404

405405
## Object Control Block
406406

407-
Data structure of kernel object control block:
407+
A simple code example snippet for data structure of kernel object control block:
408408

409409
```c
410410
struct rt_object
@@ -420,40 +420,12 @@ struct rt_object
420420
};
421421
```
422422

423-
Types currently supported by kernel objects are as follows:
423+
More details about this structure, see `struct rt_object`.
424+
425+
Regarding types currently supported by kernel objects, see:
424426

425427
```c
426428
enum rt_object_class_type
427-
{
428-
RT_Object_Class_Thread = 0, /* Object is thread type */
429-
#ifdef RT_USING_SEMAPHORE
430-
RT_Object_Class_Semaphore, /* Object is semaphore type */
431-
#endif
432-
#ifdef RT_USING_MUTEX
433-
RT_Object_Class_Mutex, /* Object is mutex type */
434-
#endif
435-
#ifdef RT_USING_EVENT
436-
RT_Object_Class_Event, /* Object is event type */
437-
#endif
438-
#ifdef RT_USING_MAILBOX
439-
RT_Object_Class_MailBox, /* Object is mailbox type */
440-
#endif
441-
#ifdef RT_USING_MESSAGEQUEUE
442-
RT_Object_Class_MessageQueue, /* Object is message queue type */
443-
#endif
444-
#ifdef RT_USING_MEMPOOL
445-
RT_Object_Class_MemPool, /* Object is memory pool type */
446-
#endif
447-
#ifdef RT_USING_DEVICE
448-
RT_Object_Class_Device, /* Object is device type */
449-
#endif
450-
RT_Object_Class_Timer, /* Object is timer type */
451-
#ifdef RT_USING_MODULE
452-
RT_Object_Class_Module, /* Object is module */
453-
#endif
454-
RT_Object_Class_Unknown, /* Object is unknown */
455-
RT_Object_Class_Static = 0x80 /* Object is a static object */
456-
};
457429
```
458430

459431
From the above type specification, we can see that if it is a static object, the highest bit of the object type will be 1 (which is the OR operation of `RT_Object_Class_Static` and other object types and operations). Otherwise it will be dynamic object, and the maximum number of object classes that the system can accommodate is 127.
@@ -486,14 +458,9 @@ void rt_object_init(struct rt_object* object ,
486458
const char* name)
487459
```
488460
489-
When this function is called to initialize the object, the system will place the object into the object container for management, that is, initialize some parameters of the object, and then insert the object node into the object linked list of the object container. Input parameters of the function is described in the following table:
490-
461+
When this function is called to initialize the object, the system will place the object into the object container for management, that is, initialize some parameters of the object, and then insert the object node into the object linked list of the object container.
491462
492-
|Parameters| Description |
493-
| -------- | ------------------------------------------------------------ |
494-
| object | The object pointer that needs to be initialized must point to a specific object memory block, not a null pointer or a wild pointer. |
495-
| type | The type of the object must be a enumeration type listed in rt_object_class_type, RT_Object_Class_Static excluded. (For static objects, or objects initialized with the rt_object_init interface, the system identifies it as an RT_Object_Class_Static type) |
496-
| name | Name of the object. Each object can be set to a name, and the maximum length for the name is specified by RT_NAME_MAX. The system does not care if it uses ’`\0`’as a terminal symbol. |
463+
More details about this function, see `rt_object_init()`.
497464
498465
### Detach Object
499466
@@ -505,25 +472,19 @@ void rt_object_detach(rt_object_t object);
505472

506473
Calling this interface makes a static kernel object to be detached from the kernel object container, meaning the corresponding object node is deleted from the kernel object container linked list. After the object is detached, the memory occupied by the object will not be released.
507474

475+
More details about this function, see `rt_object_detach()`.
476+
508477
### Allocate object
509478

510479
The above descriptions are interfaces of objects initialization and detachment, both of which are under circumstances that object-oriented memory blocks already exist. But dynamic objects can be requested when needed. The memory space is freed for other applications when not needed. To request assigning new objects, you can use the following interfaces:
511480

512481
```c
513-
rt_object_t rt_object_allocate(enum rt_object_class_typetype ,
514-
const char* name)
482+
rt_object_t rt_object_allocate(enum rt_object_class_type type, const char* name)
515483
```
516484
517-
When calling the above interface, the system first needs to obtain object information according to the object type (especially the size information of the object type for the system to allocate the correct size of the memory data block), and then allocate memory space corresponding to the size of the object from the memory heap. Next, to start necessary initialization for the object, and finally insert it into the object container linked list in which it is located. The input parameters for this function are described in the following table:
518-
485+
When calling the above interface, the system first needs to obtain object information according to the object type (especially the size information of the object type for the system to allocate the correct size of the memory data block), and then allocate memory space corresponding to the size of the object from the memory heap. Next, to start necessary initialization for the object, and finally insert it into the object container linked list in which it is located.
519486
520-
|Parameters |Description |
521-
| ------------------ | ------------------------------------------------------------ |
522-
| type | The type of the allocated object can only be of type rt_object_class_type other than RT_Object_Class_Static. In addition, the type of object allocated through this interface is dynamic, not static. |
523-
| name | Name of the object. Each object can be set to a name, and the maximum length for the name is specified by RT_NAME_MAX. The system does not care if it uses ’`\0`’as a terminal symbol. |
524-
|**Return** | - |
525-
| object handle allocated successfully | Allocate successfully |
526-
| RT_NULL | Fail to allocate |
487+
More details about this function, see `rt_object_allocate()`.
527488
528489
### Delete Object
529490
@@ -533,12 +494,9 @@ For a dynamic object, when it is no longer used, you can call the following inte
533494
void rt_object_delete(rt_object_t object);
534495
```
535496

536-
When the above interface is called, the object is first detached from the object container linked list, and then the memory occupied by the object is released. The following table describes the input parameters of the function:
497+
When the above interface is called, the object is first detached from the object container linked list, and then the memory occupied by the object is released.
537498

538-
539-
|Parameter |Description |
540-
|----------|---------------|
541-
| object | object handle |
499+
More details about this function, see `rt_object_delete()`.
542500

543501
### Identify objects
544502

@@ -548,13 +506,9 @@ Identify whether the specified object is a system object (static kernel object).
548506
rt_err_t rt_object_is_systemobject(rt_object_t object);
549507
```
550508
551-
Calling the `rt_object_is_systemobject` interface can help to identify whether an object is a system object. In RT-Thread operating system, a system object is also a static object, `RT_Object_Class_Static` bit is set to 1 on the object type identifier. Usually, objects that are initialized using the `rt_object_init()` method are system objects. The input parameters for this function are described in the following table:
552-
553-
Input parameter of `rt_object_is_systemobject()`
509+
Calling the `rt_object_is_systemobject` interface can help to identify whether an object is a system object. In RT-Thread operating system, a system object is also a static object, `RT_Object_Class_Static` bit is set to 1 on the object type identifier. Usually, objects that are initialized using the `rt_object_init()` method are system objects.
554510
555-
|**Parameter**|Description |
556-
|-------------|---------------|
557-
| object | Object handle |
511+
More details about this function, see `rt_object_is_systemobject()`.
558512
559513
## RT-Thread Kernel Configuration Example
560514

src/object.c

+25-10
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,20 @@ RTM_EXPORT(rt_object_get_pointers);
335335
* @brief This function will initialize an object and add it to object system
336336
* management.
337337
*
338-
* @param object is the specified object to be initialized.
339-
*
340-
* @param type is the object type.
341-
*
342-
* @param name is the object name. In system, the object's name must be unique.
338+
* @param object The specified object to be initialized.
339+
* The object pointer that needs to be initialized must point to
340+
* a specific object memory block, not a null pointer or a wild pointer.
341+
*
342+
* @param type The object type. The type of the object must be a enumeration
343+
* type listed in rt_object_class_type, RT_Object_Class_Static
344+
* excluded. (For static objects, or objects initialized with the
345+
* rt_object_init interface, the system identifies it as an
346+
* RT_Object_Class_Static type)
347+
*
348+
* @param name Name of the object. In system, the object's name must be unique.
349+
* Each object can be set to a name, and the maximum length for the
350+
* name is specified by RT_NAME_MAX. The system does not care if it
351+
* uses '\0' as a terminal symbol.
343352
*/
344353
void rt_object_init(struct rt_object *object,
345354
enum rt_object_class_type type,
@@ -436,11 +445,17 @@ void rt_object_detach(rt_object_t object)
436445
/**
437446
* @brief This function will allocate an object from object system.
438447
*
439-
* @param type is the type of object.
448+
* @param type Type of object. The type of the allocated object can only be of
449+
* type rt_object_class_type other than RT_Object_Class_Static.
450+
* In addition, the type of object allocated through this interface
451+
* is dynamic, not static.
440452
*
441-
* @param name is the object name. In system, the object's name must be unique.
453+
* @param name Name of the object. In system, the object's name must be unique.
454+
* Each object can be set to a name, and the maximum length for the
455+
* name is specified by RT_NAME_MAX. The system does not care if it
456+
* uses '\0' as a terminal symbol.
442457
*
443-
* @return object
458+
* @return object handle allocated successfully, or RT_NULL if no memory can be allocated.
444459
*/
445460
rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name)
446461
{
@@ -505,7 +520,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name)
505520
/**
506521
* @brief This function will delete an object and release object memory.
507522
*
508-
* @param object is the specified object to be deleted.
523+
* @param object The specified object to be deleted.
509524
*/
510525
void rt_object_delete(rt_object_t object)
511526
{
@@ -543,7 +558,7 @@ void rt_object_delete(rt_object_t object)
543558
* @note Normally, the system object is a static object and the type
544559
* of object set to RT_Object_Class_Static.
545560
*
546-
* @param object is the specified object to be judged.
561+
* @param object The specified object to be judged.
547562
*
548563
* @return RT_TRUE if a system object, RT_FALSE for others.
549564
*/

0 commit comments

Comments
 (0)