00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00033 #ifndef LIBC_IPC_DEVMAN_H_
00034 #define LIBC_IPC_DEVMAN_H_
00035
00036 #include <ipc/common.h>
00037 #include <adt/list.h>
00038 #include <malloc.h>
00039 #include <mem.h>
00040
00041 #define DEVMAN_NAME_MAXLEN 256
00042
00043 typedef sysarg_t devman_handle_t;
00044
00045 typedef enum {
00047 fun_invalid = 0,
00049 fun_inner,
00051 fun_exposed
00052 } fun_type_t;
00053
00056 typedef struct match_id {
00059 link_t link;
00062 const char *id;
00067 unsigned int score;
00068 } match_id_t;
00069
00073 typedef struct match_id_list {
00074 link_t ids;
00075 } match_id_list_t;
00076
00077 static inline match_id_t *create_match_id(void)
00078 {
00079 match_id_t *id = malloc(sizeof(match_id_t));
00080 memset(id, 0, sizeof(match_id_t));
00081 return id;
00082 }
00083
00084 static inline void delete_match_id(match_id_t *id)
00085 {
00086 if (id) {
00087 if (NULL != id->id) {
00088 free(id->id);
00089 }
00090 free(id);
00091 }
00092 }
00093
00094 static inline void add_match_id(match_id_list_t *ids, match_id_t *id)
00095 {
00096 match_id_t *mid = NULL;
00097 link_t *link = ids->ids.next;
00098
00099 while (link != &ids->ids) {
00100 mid = list_get_instance(link, match_id_t,link);
00101 if (mid->score < id->score) {
00102 break;
00103 }
00104 link = link->next;
00105 }
00106
00107 list_insert_before(&id->link, link);
00108 }
00109
00110 static inline void init_match_ids(match_id_list_t *id_list)
00111 {
00112 list_initialize(&id_list->ids);
00113 }
00114
00115 static inline void clean_match_ids(match_id_list_t *ids)
00116 {
00117 link_t *link = NULL;
00118 match_id_t *id;
00119
00120 while(!list_empty(&ids->ids)) {
00121 link = ids->ids.next;
00122 list_remove(link);
00123 id = list_get_instance(link, match_id_t, link);
00124 delete_match_id(id);
00125 }
00126 }
00127
00128 typedef enum {
00129 DEVMAN_DRIVER = 1,
00130 DEVMAN_CLIENT,
00131 DEVMAN_CONNECT_TO_DEVICE,
00132 DEVMAN_CONNECT_FROM_DEVMAP,
00133 DEVMAN_CONNECT_TO_PARENTS_DEVICE
00134 } devman_interface_t;
00135
00136 typedef enum {
00137 DEVMAN_DRIVER_REGISTER = IPC_FIRST_USER_METHOD,
00138 DEVMAN_ADD_FUNCTION,
00139 DEVMAN_ADD_MATCH_ID,
00140 DEVMAN_ADD_DEVICE_TO_CLASS
00141
00142 } driver_to_devman_t;
00143
00144 typedef enum {
00145 DRIVER_ADD_DEVICE = IPC_FIRST_USER_METHOD
00146
00147 } devman_to_driver_t;
00148
00149 typedef enum {
00150 DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD,
00151 DEVMAN_DEVICE_GET_HANDLE_BY_CLASS,
00152 DEVMAN_DEVICE_GET_DEVICE_PATH
00153 } client_to_devman_t;
00154
00155 #endif
00156