Changeset 08d9c4e6 in mainline
- Timestamp:
- 2010-02-15T21:04:59Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e85920d
- Parents:
- e2b9a993
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/Makefile.common
re2b9a993 r08d9c4e6 47 47 48 48 RD_SRVS = \ 49 $(USPACEDIR)/srv/devman/devman \ 49 50 $(USPACEDIR)/srv/bd/file_bd/file_bd \ 50 51 $(USPACEDIR)/srv/bd/part/guid_part/g_part \ -
uspace/app/init/init.c
re2b9a993 r08d9c4e6 315 315 316 316 usleep(1000000); 317 spawn("/srv/dd"); 317 //spawn("/srv/dd"); 318 319 srv_start("/srv/devman"); 318 320 319 321 return 0; -
uspace/srv/devman/devman.c
re2b9a993 r08d9c4e6 41 41 driver_t * create_driver() 42 42 { 43 printf(NAME ": create_driver\n"); 44 43 45 driver_t *res = malloc(sizeof(driver_t)); 44 46 if(res != NULL) { 45 clean_driver(res);47 init_driver(res); 46 48 } 47 49 return res; … … 102 104 bool read_match_ids(const char *conf_path, match_id_list_t *ids) 103 105 { 106 printf(NAME ": read_match_ids conf_path = %s.\n", conf_path); 107 104 108 bool suc = false; 105 109 char *buf = NULL; … … 150 154 bool get_driver_info(const char *base_path, const char *name, driver_t *drv) 151 155 { 156 printf(NAME ": get_driver_info base_path = %s, name = %s.\n", base_path, name); 157 152 158 assert(base_path != NULL && name != NULL && drv != NULL); 153 159 … … 160 166 goto cleanup; 161 167 } 168 169 printf(NAME ": get_driver_info - path to match id list = %s.\n", match_path); 162 170 163 171 if (!read_match_ids(match_path, &drv->match_ids)) { … … 208 216 int lookup_available_drivers(link_t *drivers_list, const char *dir_path) 209 217 { 218 printf(NAME ": lookup_available_drivers \n"); 219 210 220 int drv_cnt = 0; 211 221 DIR *dir = NULL; … … 213 223 214 224 dir = opendir(dir_path); 225 printf(NAME ": lookup_available_drivers has opened directory %s for driver search.\n", dir_path); 226 215 227 if (dir != NULL) { 216 228 driver_t *drv = create_driver(); 229 printf(NAME ": lookup_available_drivers has created driver structure.\n"); 217 230 while ((diren = readdir(dir))) { 218 231 if (get_driver_info(dir_path, diren->d_name, drv)) { 219 232 add_driver(drivers_list, drv); 233 drv_cnt++; 220 234 drv = create_driver(); 221 235 } … … 318 332 bool init_device_tree(dev_tree_t *tree, link_t *drivers_list) 319 333 { 334 printf(NAME ": init_device_tree."); 320 335 // create root node and add it to the device tree 321 336 if (NULL == (tree->root_node = create_root_node())) { -
uspace/srv/devman/devman.h
re2b9a993 r08d9c4e6 30 30 * @{ 31 31 */ 32 32 33 33 #ifndef DEVMAN_H_ 34 34 #define DEVMAN_H_ … … 41 41 #include <ipc/ipc.h> 42 42 43 #include "util.h" 43 44 44 45 #define NAME "devman" … … 97 98 node_t *parent; 98 99 /** Pointers to previous and next child devices in the linked list of parent device's node.*/ 99 link_t sibling; 100 link_t sibling; 100 101 /** List of child device nodes. */ 101 102 link_t children; 102 103 /** List of device ids for device-to-driver matching.*/ 103 match_id_list_t match_ids; 104 match_id_list_t match_ids; 104 105 /** Driver of this device.*/ 105 driver_t *drv; 106 driver_t *drv; 106 107 /** Pointer to the previous and next device in the list of devices 107 108 owned by one driver */ 108 link_t driver_devices; 109 link_t driver_devices; 109 110 }; 110 111 … … 130 131 131 132 132 static inline match_id_t * create_match_id() 133 static inline match_id_t * create_match_id() 133 134 { 134 135 match_id_t *id = malloc(sizeof(match_id_t)); 135 136 memset(id, 0, sizeof(match_id_t)); 136 return id; 137 } 138 139 static inline void delete_match_id(match_id_t *id) 140 { 141 free(id->id); 142 free(id); 137 return id; 138 } 139 140 static inline void delete_match_id(match_id_t *id) 141 { 142 if (id) { 143 free_not_null(id->id); 144 free(id); 145 } 143 146 } 144 147 … … 152 155 bool assign_driver(node_t *node, link_t *drivers_list); 153 156 154 void attach_driver(node_t *node, driver_t *drv); 157 void attach_driver(node_t *node, driver_t *drv); 155 158 bool add_device(driver_t *drv, node_t *node); 156 159 bool start_driver(driver_t *drv); 157 160 158 161 159 static inline void init_driver(driver_t *drv) 160 { 161 assert(drv != NULL); 162 163 memset(drv, 0, sizeof(driver_t)); 162 static inline void init_driver(driver_t *drv) 163 { 164 printf(NAME ": init_driver\n"); 165 assert(drv != NULL); 166 167 memset(drv, 0, sizeof(driver_t)); 164 168 list_initialize(&drv->match_ids.ids); 165 169 list_initialize(&drv->devices); 166 170 } 167 171 168 static inline void clean_driver(driver_t *drv) 169 { 172 static inline void clean_driver(driver_t *drv) 173 { 174 printf(NAME ": clean_driver\n"); 170 175 assert(drv != NULL); 176 177 free_not_null(drv->name); 178 free_not_null(drv->binary_path); 179 180 clean_match_ids(&drv->match_ids); 181 182 init_driver(drv); 183 } 184 185 static inline void delete_driver(driver_t *drv) 186 { 187 printf(NAME ": delete_driver\n"); 188 assert(NULL != drv); 171 189 172 free(drv->name);173 free(drv->binary_path);174 175 clean_match_ids(&drv->match_ids);176 177 init_driver(drv);178 }179 180 static inline void delete_driver(driver_t *drv)181 {182 190 clean_driver(drv); 183 191 free(drv); … … 187 195 { 188 196 list_prepend(&drv->drivers, drivers_list); 189 printf(NAME": the '%s' driver was added to the list of available drivers.\n", drv->name); 197 printf(NAME": the '%s' driver was added to the list of available drivers.\n", drv->name); 190 198 } 191 199 … … 198 206 node_t *res = malloc(sizeof(node_t)); 199 207 if (res != NULL) { 200 memset(res, 0, sizeof(node_t)); 208 memset(res, 0, sizeof(node_t)); 201 209 } 202 210 return res; 203 211 } 204 212 205 static inline void init_dev_node(node_t *node, node_t *parent) 213 static inline void init_dev_node(node_t *node, node_t *parent) 206 214 { 207 215 assert(NULL != node); 208 216 209 217 node->parent = parent; 210 218 if (NULL != parent) { 211 219 list_append(&node->sibling, &parent->children); 212 220 } 213 221 214 222 list_initialize(&node->children); 215 216 list_initialize(&node->match_ids.ids); 223 224 list_initialize(&node->match_ids.ids); 217 225 } 218 226 -
uspace/srv/devman/main.c
re2b9a993 r08d9c4e6 92 92 static bool devman_init() 93 93 { 94 printf(NAME ": devman_init - looking for available drivers. \n"); 95 94 96 // initialize list of available drivers 95 97 if (0 == lookup_available_drivers(&drivers_list, DRIVER_DEFAULT_STORE)) { … … 97 99 return false; 98 100 } 101 printf(NAME ": devman_init - list of drivers has been initialized. \n"); 99 102 100 103 // create root device node -
uspace/srv/devman/util.c
re2b9a993 r08d9c4e6 41 41 char *res; 42 42 int base_len = str_size(base_path); 43 int size = base_len + str_size(name) + str_size(ext) + 3;43 int size = base_len + 2*str_size(name) + str_size(ext) + 3; 44 44 45 45 res = malloc(size); … … 51 51 } 52 52 str_append(res, size, name); 53 str_append(res, size, "/"); 54 str_append(res, size, name); 53 55 if(ext[0] != '.') { 54 56 str_append(res, size, "."); -
uspace/srv/devman/util.h
re2b9a993 r08d9c4e6 57 57 } 58 58 59 static inline void free_not_null(void *ptr) 60 { 61 if (NULL != ptr) { 62 free(ptr); 63 } 64 } 65 59 66 #endif
Note:
See TracChangeset
for help on using the changeset viewer.