1 /*
2  * Copyright (C) 2015-2020 Alibaba Group Holding Limited
3  */
4 
5 #ifndef _AOS_OBJECT_H
6 #define _AOS_OBJECT_H
7 
8 #include <stdint.h>
9 #include <stddef.h>
10 #include <stdbool.h>
11 
12 #include "aos/list.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #ifndef AOS_OBJ_NAME_MAX
19 #define AOS_OBJ_NAME_MAX 10
20 #endif
21 
22 #ifndef AOS_ALIGN
23 #define AOS_ALIGN(size, align)           (((size) + (align) - 1) & ~((align) - 1))
24 #endif
25 
26 #ifndef AOS_ALIGN_SIZE
27 #define AOS_ALIGN_SIZE  4
28 #endif
29 
30 enum aos_object_class_type
31 {
32     AOS_Object_Class_Null   = 0,                         /**< The object is not used. */
33     AOS_Object_Class_Thread,                             /**< The object is a thread. */
34     AOS_Object_Class_Semaphore,                          /**< The object is a semaphore. */
35     AOS_Object_Class_Mutex,                              /**< The object is a mutex. */
36     AOS_Object_Class_Event,                              /**< The object is a event. */
37     AOS_Object_Class_MailBox,                            /**< The object is a mail box. */
38     AOS_Object_Class_MessageQueue,                       /**< The object is a message queue. */
39     AOS_Object_Class_MemHeap,                            /**< The object is a memory heap */
40     AOS_Object_Class_MemPool,                            /**< The object is a memory pool. */
41     AOS_Object_Class_Device,                             /**< The object is a device */
42     AOS_Object_Class_Timer,                              /**< The object is a timer. */
43     AOS_Object_Class_Module,                             /**< The object is a module. */
44     AOS_Object_Class_Unknown,                            /**< The object is unknown. */
45     AOS_Object_Class_Static = 0x80                       /**< The object is a static object. */
46 };
47 
48 struct aos_object
49 {
50     char    name[AOS_OBJ_NAME_MAX];                  /**< name of kernel object */
51     uint8_t type;                                    /**< type of kernel object */
52     uint8_t flag;                                    /**< flag of kernel object */
53 
54 #ifdef AOS_USING_MODULE
55     void      *module_id;                               /**< id of application module */
56 #endif
57     dlist_t  list;                                    /**< list node of kernel object */
58 };
59 
60 typedef struct aos_object *aos_object_t;
61 
62 /**
63  * The information of the kernel object
64  */
65 struct aos_object_information
66 {
67     enum aos_object_class_type  type;                     /**< object class type */
68     dlist_t                     object_list;              /**< object list */
69     size_t                      object_size;              /**< object size */
70 };
71 
72 
73 void aos_object_init(struct aos_object      *object,
74                      enum aos_object_class_type type,
75                      const char               *name);
76 
77 struct aos_object_information *
78 aos_object_get_information(enum aos_object_class_type type);
79 
80 #ifdef AOS_USING_MODULE
81 struct aos_dlmodule {
82     /* modeule definition */
83 };
84 #endif
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 
91 #endif
92