Changeset d347b53 in mainline
- Timestamp:
- 2010-03-21T19:33:58Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 66babbd
- Parents:
- bda60d9
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
.bzrignore
rbda60d9 rd347b53 1 1 HelenOS.sparc64.simics 2 make_settings -
uspace/lib/libc/generic/devman.c
rbda60d9 rd347b53 108 108 int devman_child_device_register( 109 109 const char *name, match_id_list_t *match_ids, device_handle_t parent_handle, device_handle_t *handle) 110 { 110 { 111 111 int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING); 112 112 -
uspace/lib/libdrv/generic/driver.c
rbda60d9 rd347b53 72 72 // result of the operation - device was added, device is not present etc. 73 73 ipcarg_t ret = 0; 74 device_handle_t dev_handle = IPC_GET_ARG1(*icall); 75 76 printf("%s: adding device with handle = %x \n", driver->name, dev_handle); 77 74 device_handle_t dev_handle = IPC_GET_ARG1(*icall); 78 75 device_t *dev = driver_create_device(); 79 76 dev->handle = dev_handle; … … 82 79 // TODO set return value 83 80 } 81 printf("%s: new device with handle = %x was added.\n", driver->name, dev_handle); 84 82 85 ipc _answer_1(iid, EOK, ret);83 ipcarg_t r = ipc_answer_1(iid, EOK, ret); 86 84 } 87 85 … … 168 166 169 167 // register driver by device manager with generic handler for incoming connections 170 printf("%s: sending registration request to devman.\n", driver->name);171 168 devman_driver_register(driver->name, driver_connection); 172 169 -
uspace/srv/devman/devman.c
rbda60d9 rd347b53 233 233 } 234 234 235 printf(NAME ": get_driver_info - path to match id list = %s.\n", match_path);236 237 235 if (!read_match_ids(match_path, &drv->match_ids)) { 238 236 goto cleanup; … … 284 282 int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path) 285 283 { 286 printf(NAME ": lookup_available_drivers \n");284 printf(NAME ": lookup_available_drivers, dir = %s \n", dir_path); 287 285 288 286 int drv_cnt = 0; … … 291 289 292 290 dir = opendir(dir_path); 293 printf(NAME ": lookup_available_drivers has opened directory %s for driver search.\n", dir_path);294 291 295 292 if (dir != NULL) { 296 293 driver_t *drv = create_driver(); 297 printf(NAME ": lookup_available_drivers has created driver structure.\n");298 294 while ((diren = readdir(dir))) { 299 295 if (get_driver_info(dir_path, diren->d_name, drv)) { … … 345 341 driver_t * find_best_match_driver(driver_list_t *drivers_list, node_t *node) 346 342 { 347 printf(NAME ": find_best_match_driver \n");343 printf(NAME ": find_best_match_driver for device '%s' \n", node->pathname); 348 344 driver_t *best_drv = NULL, *drv = NULL; 349 345 int best_score = 0, score = 0; … … 392 388 bool start_driver(driver_t *drv) 393 389 { 394 printf(NAME ": start_driver \n");390 printf(NAME ": start_driver '%s'\n", drv->name); 395 391 396 392 char *argv[2]; 397 398 printf(NAME ": spawning driver %s\n", drv->name);399 393 400 394 argv[0] = drv->name; … … 459 453 static void pass_devices_to_driver(driver_t *driver) 460 454 { 455 printf(NAME ": pass_devices_to_driver\n"); 461 456 node_t *dev; 462 457 link_t *link; … … 486 481 void initialize_running_driver(driver_t *driver) 487 482 { 483 printf(NAME ": initialize_running_driver\n"); 488 484 fibril_mutex_lock(&driver->driver_mutex); 489 485 … … 533 529 driver_t *drv = find_best_match_driver(drivers_list, node); 534 530 if (NULL == drv) { 535 printf(NAME ": no driver found for device .\n");531 printf(NAME ": no driver found for device '%s'.\n", node->pathname); 536 532 return false; 537 533 } … … 626 622 printf(NAME ": insert_dev_node\n"); 627 623 628 assert(NULL != node && NULL != tree && dev_name != NULL);624 assert(NULL != node && NULL != tree && NULL != dev_name); 629 625 630 626 node->name = dev_name; -
uspace/srv/devman/devman.h
rbda60d9 rd347b53 141 141 // Drivers 142 142 143 /** 144 * Initialize the list of device driver's. 145 * 146 * @param drv_list the list of device driver's. 147 * 148 */ 143 149 static inline void init_driver_list(driver_list_t *drv_list) 144 150 { … … 165 171 void initialize_running_driver(driver_t *driver); 166 172 167 173 /** 174 * Initialize device driver structure. 175 * 176 * @param drv the device driver structure. 177 * 178 */ 168 179 static inline void init_driver(driver_t *drv) 169 180 { … … 176 187 } 177 188 189 /** 190 * Device driver structure clean-up. 191 * 192 * @param drv the device driver structure. 193 */ 178 194 static inline void clean_driver(driver_t *drv) 179 195 { … … 188 204 } 189 205 206 /** 207 * Delete device driver structure. 208 * 209 * @param drv the device driver structure.* 210 */ 190 211 static inline void delete_driver(driver_t *drv) 191 212 { … … 197 218 198 219 // Device nodes 199 220 /** 221 * Create a new device node. 222 * 223 * @return a device node structure. 224 * 225 */ 200 226 static inline node_t * create_dev_node() 201 227 { … … 207 233 list_initialize(&res->children); 208 234 list_initialize(&res->match_ids.ids); 235 fibril_mutex_initialize(&res->children_mutex); 209 236 210 237 return res; 211 238 } 212 239 240 static inline void delete_dev_node(node_t *node) 241 { 242 assert(list_empty(&node->children) && NULL == node->parent && NULL == node->drv); 243 244 clean_match_ids(&node->match_ids); 245 free_not_null(node->name); 246 free_not_null(node->pathname); 247 free(node); 248 } 249 250 /** 251 * Find the device node structure of the device witch has the specified handle. 252 * 253 * @param tree the device tree where we look for the device node. 254 * @param handle the handle of the device. 255 * @return the device node. 256 */ 213 257 static inline node_t * find_dev_node(dev_tree_t *tree, long handle) 214 258 { -
uspace/srv/devman/main.c
rbda60d9 rd347b53 51 51 #include <ctype.h> 52 52 #include <ipc/devman.h> 53 #include <thread.h> 53 54 54 55 #include "devman.h" … … 96 97 return NULL; 97 98 } 98 printf(NAME ": registering the running instance of the %s driver.\n", driver->name);99 99 100 100 // Create connection to the driver … … 123 123 { 124 124 printf(NAME ": devman_add_child\n"); 125 126 // TODO 127 125 126 device_handle_t parent_handle = IPC_GET_ARG1(*call); 127 node_t *parent = find_dev_node(&device_tree, parent_handle); 128 129 if (NULL == parent) { 130 ipc_answer_0(callid, ENOENT); 131 return; 132 } 133 134 char *dev_name = NULL; 135 int rc = async_string_receive(&dev_name, DEVMAN_NAME_MAXLEN, NULL); 136 if (rc != EOK) { 137 ipc_answer_0(callid, rc); 138 return; 139 } 140 printf(NAME ": newly added child device's name is '%s'.\n", dev_name); 141 142 node_t *node = create_dev_node(); 143 if (!insert_dev_node(&device_tree, node, dev_name, parent)) { 144 delete_dev_node(node); 145 ipc_answer_0(callid, ENOMEM); 146 return; 147 } 148 149 // TODO match ids 150 151 // return device handle to parent's driver 152 ipc_answer_1(callid, EOK, node->handle); 153 154 // try to find suitable driver and assign it to the device 155 assign_driver(node, &drivers_list); 156 } 157 158 static int init_running_drv(void *drv) 159 { 160 driver_t *driver = (driver_t *)drv; 161 initialize_running_driver(driver); 162 printf(NAME ": the %s driver was successfully initialized. \n", driver->name); 163 return 0; 128 164 } 129 165 … … 137 173 138 174 driver_t *driver = devman_driver_register(); 139 if (driver == NULL) 140 return; 141 142 initialize_running_driver(driver); 175 if (NULL == driver) 176 return; 177 178 fid_t fid = fibril_create(init_running_drv, driver); 179 if (fid == 0) { 180 printf(NAME ": Error creating fibril for the initialization of the newly registered running driver.\n"); 181 exit(1); 182 } 183 fibril_add_ready(fid); 184 185 /*thread_id_t tid; 186 if (0 != thread_create(init_running_drv, driver, "init_running_drv", &tid)) { 187 printf(NAME ": failed to start the initialization of the newly registered running driver.\n"); 188 }*/ 143 189 144 190 ipc_callid_t callid; -
uspace/srv/drivers/root/root.c
rbda60d9 rd347b53 75 75 } 76 76 77 // TODO - replace this with some better solution 77 // TODO - replace this with some better solution (sysinfo ?) 78 78 platform->name = STRING(UARCH); 79 79 printf(NAME ": the new device's name is %s.\n", platform->name); … … 113 113 // register root device's children 114 114 if (!add_platform_child(dev)) { 115 printf(NAME ": failed to add child device for platform.\n"); 115 116 return false; 116 117 }
Note:
See TracChangeset
for help on using the changeset viewer.