Changeset 7bdcc45 in mainline for uspace/drv/root/root.c
- Timestamp:
- 2010-12-16T16:38:49Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7837101
- Parents:
- 8e58f94 (diff), eb221e5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/root/root.c
r8e58f94 r7bdcc45 1 1 /* 2 2 * Copyright (c) 2010 Lenka Trochtova 3 * Copyright (c) 2010 Vojtech Horky 3 4 * All rights reserved. 4 5 * … … 45 46 #include <ctype.h> 46 47 #include <macros.h> 48 #include <inttypes.h> 47 49 48 50 #include <driver.h> … … 51 53 52 54 #define NAME "root" 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 53 63 54 64 static int root_add_device(device_t *dev); … … 65 75 }; 66 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 67 94 /** Create the device which represents the root of HW device tree. 68 95 * … … 73 100 { 74 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); 75 104 76 int res = EOK; 77 device_t *platform = NULL; 78 match_id_t *match_id = NULL; 79 80 /* Create new device. */ 81 platform = create_device(); 82 if (NULL == platform) { 83 res = ENOMEM; 84 goto failure; 85 } 86 87 platform->name = "hw"; 88 printf(NAME ": the new device's name is %s.\n", platform->name); 89 90 /* Initialize match id list. */ 91 match_id = create_match_id(); 92 if (NULL == match_id) { 93 res = ENOMEM; 94 goto failure; 95 } 96 97 /* TODO - replace this with some better solution (sysinfo ?) */ 98 match_id->id = STRING(UARCH); 99 match_id->score = 100; 100 add_match_id(&platform->match_ids, match_id); 101 102 /* Register child device. */ 103 res = child_device_register(platform, parent); 104 if (EOK != res) 105 goto failure; 106 107 return res; 108 109 failure: 110 if (NULL != match_id) 111 match_id->id = NULL; 112 113 if (NULL != platform) { 114 platform->name = NULL; 115 delete_device(platform); 116 } 117 105 int res = child_device_register_wrapper(parent, PLATFORM_DEVICE_NAME, 106 PLATFORM_DEVICE_MATCH_ID, PLATFORM_DEVICE_MATCH_SCORE); 107 118 108 return res; 119 109 } … … 126 116 static int root_add_device(device_t *dev) 127 117 { 128 printf(NAME ": root_add_device, device handle = %d\n", dev->handle); 118 printf(NAME ": root_add_device, device handle=%" PRIun "\n", 119 dev->handle); 129 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 130 128 /* Register root device's children. */ 131 129 int res = add_platform_child(dev);
Note:
See TracChangeset
for help on using the changeset viewer.