Changeset 66babbd in mainline
- Timestamp:
- 2010-03-25T09:55:09Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a087f2e
- Parents:
- d347b53
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/devman.c
rd347b53 r66babbd 39 39 #include <malloc.h> 40 40 #include <bool.h> 41 #include <adt/list.h> 41 42 42 43 static int devman_phone_driver = -1; … … 106 107 } 107 108 109 static int devman_send_match_id(int phone, match_id_t *match_id) \ 110 { 111 ipc_call_t answer; 112 async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer); 113 int retval = async_data_write_start(phone, match_id->id, str_size(match_id->id)); 114 return retval; 115 } 116 117 118 static int devman_send_match_ids(int phone, match_id_list_t *match_ids) 119 { 120 link_t *link = match_ids->ids.next; 121 match_id_t *match_id = NULL; 122 int ret = EOK; 123 124 while (link != &match_ids->ids) { 125 match_id = list_get_instance(link, match_id_t, link); 126 if (EOK != (ret = devman_send_match_id(phone, match_id))) 127 { 128 printf("Driver failed to send match id, error number = %d\n", ret); 129 return ret; 130 } 131 link = link->next; 132 } 133 return ret; 134 } 135 108 136 int devman_child_device_register( 109 137 const char *name, match_id_list_t *match_ids, device_handle_t parent_handle, device_handle_t *handle) … … 116 144 async_serialize_start(); 117 145 146 int match_count = list_count(&match_ids->ids); 118 147 ipc_call_t answer; 119 aid_t req = async_send_ 1(phone, DEVMAN_ADD_CHILD_DEVICE, parent_handle, &answer);148 aid_t req = async_send_2(phone, DEVMAN_ADD_CHILD_DEVICE, parent_handle, match_count, &answer); 120 149 121 150 ipcarg_t retval = async_data_write_start(phone, name, str_size(name)); … … 126 155 } 127 156 128 // TODO match ids157 devman_send_match_ids(phone, match_ids); 129 158 130 159 async_wait_for(req, &retval); … … 141 170 if (handle != NULL) 142 171 *handle = (int) IPC_GET_ARG1(answer); 172 173 return retval; 143 174 } 144 175 -
uspace/lib/libc/include/ipc/devman.h
rd347b53 r66babbd 51 51 /** Id of device model. 52 52 */ 53 c onst char *id;53 char *id; 54 54 /** Relevancy of device-to-driver match. 55 55 * The higher is the product of scores specified for the device by the bus driver and by the leaf driver, … … 121 121 typedef enum { 122 122 DEVMAN_DRIVER_REGISTER = IPC_FIRST_USER_METHOD, 123 DEVMAN_ADD_CHILD_DEVICE 123 DEVMAN_ADD_CHILD_DEVICE, 124 DEVMAN_ADD_MATCH_ID 124 125 125 126 } driver_to_devman_t; -
uspace/lib/libdrv/generic/driver.c
rd347b53 r66babbd 47 47 #include <string.h> 48 48 #include <ctype.h> 49 #include <errno.h> 49 50 50 51 #include <devman.h> … … 153 154 assert(NULL != child->name); 154 155 155 if (devman_child_device_register(child->name, &child->match_ids, parent->handle, &child->handle)) { 156 // TODO initialize child device 156 if (EOK == devman_child_device_register(child->name, &child->match_ids, parent->handle, &child->handle)) { 157 157 return true; 158 158 } -
uspace/srv/devman/main.c
rd347b53 r66babbd 120 120 } 121 121 122 static int devman_receive_match_id(match_id_list_t *match_ids) { 123 124 match_id_t *match_id = create_match_id(); 125 ipc_callid_t callid; 126 ipc_call_t call; 127 int rc = 0; 128 129 callid = async_get_call(&call); 130 if (DEVMAN_ADD_MATCH_ID != IPC_GET_METHOD(call)) { 131 printf(NAME ": ERROR: devman_receive_match_id - invalid protocol.\n"); 132 ipc_answer_0(callid, EINVAL); 133 delete_match_id(match_id); 134 return EINVAL; 135 } 136 137 if (NULL == match_id) { 138 printf(NAME ": ERROR: devman_receive_match_id - failed to allocate match id.\n"); 139 ipc_answer_0(callid, ENOMEM); 140 return ENOMEM; 141 } 142 143 match_id->score = IPC_GET_ARG1(call); 144 145 rc = async_string_receive(&match_id->id, DEVMAN_NAME_MAXLEN, NULL); 146 if (EOK != rc) { 147 delete_match_id(match_id); 148 return rc; 149 } 150 151 list_append(&match_id->link, &match_ids->ids); 152 return rc; 153 } 154 155 static int devman_receive_match_ids(ipcarg_t match_count, match_id_list_t *match_ids) 156 { 157 int ret = EOK; 158 int i; 159 for (i = 0; i < match_count; i++) { 160 if (EOK != (ret = devman_receive_match_id(match_ids))) { 161 return ret; 162 } 163 } 164 return ret; 165 } 166 122 167 static void devman_add_child(ipc_callid_t callid, ipc_call_t *call, driver_t *driver) 123 168 { 124 169 printf(NAME ": devman_add_child\n"); 125 170 126 171 device_handle_t parent_handle = IPC_GET_ARG1(*call); 172 ipcarg_t match_count = IPC_GET_ARG2(*call); 173 127 174 node_t *parent = find_dev_node(&device_tree, parent_handle); 128 175 … … 130 177 ipc_answer_0(callid, ENOENT); 131 178 return; 132 } 179 } 133 180 134 181 char *dev_name = NULL; 135 182 int rc = async_string_receive(&dev_name, DEVMAN_NAME_MAXLEN, NULL); 136 if ( rc != EOK) {183 if (EOK != rc) { 137 184 ipc_answer_0(callid, rc); 138 185 return; … … 147 194 } 148 195 149 // TODO match ids196 devman_receive_match_ids(match_count, &node->match_ids); 150 197 151 198 // return device handle to parent's driver -
uspace/srv/drivers/root/root.c
rd347b53 r66babbd 55 55 static bool root_init(); 56 56 57 /** The root device driver's standard operations. 58 */ 57 59 static driver_ops_t root_ops = { 58 60 .add_device = &root_add_device 59 61 }; 60 62 63 /** The root device driver structure. 64 */ 61 65 static driver_t root_driver = { 62 66 .name = NAME, … … 64 68 }; 65 69 70 /** Create the device which represents the root of HW device tree. 71 * @param parent parent of the newly created device. 72 */ 66 73 static bool add_platform_child(device_t *parent) { 67 74 printf(NAME ": adding new child for platform device.\n"); … … 107 114 } 108 115 116 /** Get the root device. 117 * @param dev the device which is root of the whole device tree (both of HW and pseudo devices). 118 */ 109 119 static bool root_add_device(device_t *dev) 110 120 {
Note:
See TracChangeset
for help on using the changeset viewer.