Changes in / [41a7f62:ab3a851] in mainline
- Files:
-
- 7 added
- 3 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/Makefile.common
r41a7f62 rab3a851 109 109 110 110 RD_DRVS = \ 111 root 111 root \ 112 rootvirt 112 113 113 114 RD_DRV_CFG = -
boot/arch/amd64/Makefile.inc
r41a7f62 rab3a851 37 37 38 38 RD_DRVS += \ 39 root ia32\39 rootpc \ 40 40 pciintel \ 41 41 isa \ -
uspace/Makefile
r41a7f62 rab3a851 85 85 srv/net/tl/tcp \ 86 86 srv/net/net \ 87 drv/root 87 drv/root \ 88 drv/rootvirt 88 89 89 90 ## Networking … … 108 109 109 110 ifeq ($(UARCH),amd64) 111 DIRS += drv/rootpc 112 DIRS += drv/pciintel 113 DIRS += drv/isa 114 DIRS += drv/ns8250 110 115 endif 111 116 112 117 ifeq ($(UARCH),ia32) 113 DIRS += drv/root ia32118 DIRS += drv/rootpc 114 119 DIRS += drv/pciintel 115 120 DIRS += drv/isa -
uspace/drv/isa/isa.c
r41a7f62 rab3a851 282 282 283 283 printf(NAME ": added io range (addr=0x%x, size=0x%x) to " 284 "device %s\n", addr, len, dev->name); 284 "device %s\n", (unsigned int) addr, (unsigned int) len, 285 dev->name); 285 286 } 286 287 } … … 489 490 static int isa_add_device(device_t *dev) 490 491 { 491 printf(NAME ": isa_add_device, device handle = %d\n", dev->handle); 492 printf(NAME ": isa_add_device, device handle = %d\n", 493 (int) dev->handle); 492 494 493 495 /* Add child devices. */ -
uspace/drv/ns8250/ns8250.c
r41a7f62 rab3a851 274 274 275 275 /* Gain control over port's registers. */ 276 if (pio_enable((void *) data->io_addr, REG_COUNT,276 if (pio_enable((void *)(uintptr_t) data->io_addr, REG_COUNT, 277 277 (void **) &data->port)) { 278 278 printf(NAME ": error - cannot gain the port %#" PRIx32 " for device " … … 727 727 { 728 728 printf(NAME ": ns8250_add_device %s (handle = %d)\n", 729 dev->name, dev->handle);729 dev->name, (int) dev->handle); 730 730 731 731 int res = ns8250_dev_initialize(dev); -
uspace/drv/pciintel/pci.c
r41a7f62 rab3a851 324 324 printf(NAME ": device %s : ", dev->name); 325 325 printf("address = %" PRIx64, range_addr); 326 printf(", size = %x\n", range_size);326 printf(", size = %x\n", (unsigned int) range_size); 327 327 } 328 328 … … 489 489 (uint32_t) hw_resources.resources[0].res.io_range.address; 490 490 491 if (pio_enable((void *) bus_data->conf_io_addr, 8,491 if (pio_enable((void *)(uintptr_t)bus_data->conf_io_addr, 8, 492 492 &bus_data->conf_addr_port)) { 493 493 printf(NAME ": failed to enable configuration ports.\n"); -
uspace/drv/root/root.c
r41a7f62 rab3a851 1 1 /* 2 2 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2010 Vojtech Horky 3 4 * All rights reserved. 4 5 * … … 53 54 #define NAME "root" 54 55 56 #define PLATFORM_DEVICE_NAME "hw" 57 #define PLATFORM_DEVICE_MATCH_ID STRING(UARCH) 58 #define PLATFORM_DEVICE_MATCH_SCORE 100 59 60 #define VIRTUAL_DEVICE_NAME "virt" 61 #define VIRTUAL_DEVICE_MATCH_ID "rootvirt" 62 #define VIRTUAL_DEVICE_MATCH_SCORE 100 63 55 64 static int root_add_device(device_t *dev); 56 65 … … 66 75 }; 67 76 77 /** Create the device which represents the root of virtual device tree. 78 * 79 * @param parent Parent of the newly created device. 80 * @return Error code. 81 */ 82 static int add_virtual_root_child(device_t *parent) 83 { 84 printf(NAME ": adding new child for virtual devices.\n"); 85 printf(NAME ": device node is `%s' (%d %s)\n", VIRTUAL_DEVICE_NAME, 86 VIRTUAL_DEVICE_MATCH_SCORE, VIRTUAL_DEVICE_MATCH_ID); 87 88 int res = child_device_register_wrapper(parent, VIRTUAL_DEVICE_NAME, 89 VIRTUAL_DEVICE_MATCH_ID, VIRTUAL_DEVICE_MATCH_SCORE); 90 91 return res; 92 } 93 68 94 /** Create the device which represents the root of HW device tree. 69 95 * … … 74 100 { 75 101 printf(NAME ": adding new child for platform device.\n"); 102 printf(NAME ": device node is `%s' (%d %s)\n", PLATFORM_DEVICE_NAME, 103 PLATFORM_DEVICE_MATCH_SCORE, PLATFORM_DEVICE_MATCH_ID); 76 104 77 int res = EOK; 78 device_t *platform = NULL; 79 match_id_t *match_id = NULL; 80 81 /* Create new device. */ 82 platform = create_device(); 83 if (NULL == platform) { 84 res = ENOMEM; 85 goto failure; 86 } 87 88 platform->name = "hw"; 89 printf(NAME ": the new device's name is %s.\n", platform->name); 90 91 /* Initialize match id list. */ 92 match_id = create_match_id(); 93 if (NULL == match_id) { 94 res = ENOMEM; 95 goto failure; 96 } 97 98 /* TODO - replace this with some better solution (sysinfo ?) */ 99 match_id->id = STRING(UARCH); 100 match_id->score = 100; 101 add_match_id(&platform->match_ids, match_id); 102 103 /* Register child device. */ 104 res = child_device_register(platform, parent); 105 if (EOK != res) 106 goto failure; 107 108 return res; 109 110 failure: 111 if (NULL != match_id) 112 match_id->id = NULL; 113 114 if (NULL != platform) { 115 platform->name = NULL; 116 delete_device(platform); 117 } 118 105 int res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME, 106 PLATFORM_DEVICE_MATCH_ID, PLATFORM_DEVICE_MATCH_SCORE); 107 119 108 return res; 120 109 } … … 130 119 dev->handle); 131 120 121 /* 122 * Register virtual devices root. 123 * We ignore error occurrence because virtual devices shall not be 124 * vital for the system. 125 */ 126 add_virtual_root_child(dev); 127 132 128 /* Register root device's children. */ 133 129 int res = add_platform_child(dev); -
uspace/lib/drv/generic/driver.c
r41a7f62 rab3a851 165 165 166 166 devman_handle_t dev_handle = IPC_GET_ARG1(*icall); 167 devman_handle_t parent_dev_handle = IPC_GET_ARG2(*icall); 168 167 169 device_t *dev = create_device(); 168 170 dev->handle = dev_handle; … … 172 174 173 175 add_to_devices_list(dev); 176 dev->parent = driver_get_device(&devices, parent_dev_handle); 177 174 178 res = driver->driver_ops->add_device(dev); 175 179 if (0 == res) { … … 377 381 } 378 382 383 /** Wrapper for child_device_register for devices with single match id. 384 * 385 * @param parent Parent device. 386 * @param child_name Child device name. 387 * @param child_match_id Child device match id. 388 * @param child_match_score Child device match score. 389 * @return Error code. 390 */ 391 int child_device_register_wrapper(device_t *parent, const char *child_name, 392 const char *child_match_id, int child_match_score) 393 { 394 device_t *child = NULL; 395 match_id_t *match_id = NULL; 396 int rc; 397 398 child = create_device(); 399 if (child == NULL) { 400 rc = ENOMEM; 401 goto failure; 402 } 403 404 child->name = child_name; 405 406 match_id = create_match_id(); 407 if (match_id == NULL) { 408 rc = ENOMEM; 409 goto failure; 410 } 411 412 match_id->id = child_match_id; 413 match_id->score = child_match_score; 414 add_match_id(&child->match_ids, match_id); 415 416 rc = child_device_register(child, parent); 417 if (EOK != rc) 418 goto failure; 419 420 goto leave; 421 422 failure: 423 if (match_id != NULL) { 424 match_id->id = NULL; 425 delete_match_id(match_id); 426 } 427 428 if (child != NULL) { 429 child->name = NULL; 430 delete_device(child); 431 } 432 433 leave: 434 return rc; 435 } 436 379 437 int driver_main(driver_t *drv) 380 438 { -
uspace/lib/drv/include/driver.h
r41a7f62 rab3a851 199 199 200 200 int child_device_register(device_t *, device_t *); 201 int child_device_register_wrapper(device_t *, const char *, const char *, int); 201 202 202 203 -
uspace/srv/devman/devman.c
r41a7f62 rab3a851 643 643 644 644 /* Send the device to the driver. */ 645 aid_t req = async_send_1(phone, DRIVER_ADD_DEVICE, node->handle, 646 &answer); 645 devman_handle_t parent_handle; 646 if (node->parent) { 647 parent_handle = node->parent->handle; 648 } else { 649 parent_handle = 0; 650 } 651 aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, node->handle, 652 parent_handle, &answer); 647 653 648 654 /* Send the device's name to the driver. */ -
uspace/srv/devman/match.c
r41a7f62 rab3a851 35 35 #include "devman.h" 36 36 37 /** Compute compound score of driver and device. 38 * 39 * @param driver Match id of the driver. 40 * @param device Match id of the device. 41 * @return Compound score. 42 * @retval 0 No match at all. 43 */ 44 static int compute_match_score(match_id_t *driver, match_id_t *device) 45 { 46 if (str_cmp(driver->id, device->id) == 0) { 47 /* 48 * The strings matches, return their score multiplied. 49 */ 50 return driver->score * device->score; 51 } else { 52 /* 53 * Different strings, return zero. 54 */ 55 return 0; 56 } 57 } 58 37 59 int get_match_score(driver_t *drv, node_t *dev) 38 60 { … … 43 65 return 0; 44 66 67 /* 68 * Go through all pairs, return the highest score obtainetd. 69 */ 70 int highest_score = 0; 71 45 72 link_t *drv_link = drv->match_ids.ids.next; 46 link_t *dev_link = dev->match_ids.ids.next; 47 48 match_id_t *drv_id = list_get_instance(drv_link, match_id_t, link); 49 match_id_t *dev_id = list_get_instance(dev_link, match_id_t, link); 50 51 int score_next_drv = 0; 52 int score_next_dev = 0; 53 54 do { 55 match_id_t *tmp_ma_id; 56 57 if (str_cmp(drv_id->id, dev_id->id) == 0) { 58 /* 59 * We found a match. 60 * Return the score of the match. 61 */ 62 return drv_id->score * dev_id->score; 73 while (drv_link != drv_head) { 74 link_t *dev_link = dev_head->next; 75 while (dev_link != dev_head) { 76 match_id_t *drv_id = list_get_instance(drv_link, match_id_t, link); 77 match_id_t *dev_id = list_get_instance(dev_link, match_id_t, link); 78 79 int score = compute_match_score(drv_id, dev_id); 80 if (score > highest_score) { 81 highest_score = score; 82 } 83 84 dev_link = dev_link->next; 63 85 } 64 86 65 /* 66 * Compute the next score we get, if we advance in the driver's 67 * list of match ids. 68 */ 69 if (drv_link->next != drv_head) { 70 tmp_ma_id = list_get_instance(drv_link->next, 71 match_id_t, link); 72 score_next_drv = dev_id->score * tmp_ma_id->score; 73 } else { 74 score_next_drv = 0; 75 } 76 77 /* 78 * Compute the next score we get, if we advance in the device's 79 * list of match ids. 80 */ 81 if (dev_link->next != dev_head) { 82 tmp_ma_id = list_get_instance(dev_link->next, 83 match_id_t, link); 84 score_next_dev = drv_id->score * tmp_ma_id->score; 85 } else { 86 score_next_dev = 0; 87 } 88 89 /* 90 * Advance in one of the two lists, so we get the next highest 91 * score. 92 */ 93 if (score_next_drv > score_next_dev) { 94 drv_link = drv_link->next; 95 drv_id = list_get_instance(drv_link, match_id_t, link); 96 } else { 97 dev_link = dev_link->next; 98 dev_id = list_get_instance(dev_link, match_id_t, link); 99 } 100 101 } while (drv_link->next != drv_head && dev_link->next != dev_head); 87 drv_link = drv_link->next; 88 } 102 89 103 return 0;90 return highest_score; 104 91 } 105 92
Note: See TracChangeset
for help on using the changeset viewer.