Changeset 92574f4 in mainline for uspace/lib/c/generic/devman.c
- Timestamp:
- 2011-02-24T12:03:27Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e7b7ebd5
- Parents:
- 4837092 (diff), a80849c (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/lib/c/generic/devman.c
r4837092 r92574f4 28 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 29 */ 30 31 30 31 /** @addtogroup libc 32 32 * @{ 33 33 */ … … 37 37 #include <str.h> 38 38 #include <stdio.h> 39 #include <ipc/ipc.h>40 39 #include <ipc/services.h> 41 40 #include <ipc/devman.h> … … 116 115 async_set_client_connection(conn); 117 116 118 ipc_connect_to_me(phone, 0, 0, 0, NULL, NULL);117 async_connect_to_me(phone, 0, 0, 0, NULL); 119 118 async_wait_for(req, &retval); 120 119 … … 124 123 } 125 124 126 static int devman_send_match_id(int phone, match_id_t *match_id) \ 127 { 128 ipc_call_t answer; 129 aid_t req = async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer); 130 int retval = async_data_write_start(phone, match_id->id, str_size(match_id->id)); 125 static int devman_send_match_id(int phone, match_id_t *match_id) 126 { 127 ipc_call_t answer; 128 129 aid_t req = async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, 130 &answer); 131 int retval = async_data_write_start(phone, match_id->id, 132 str_size(match_id->id)); 133 131 134 async_wait_for(req, NULL); 132 135 return retval; … … 134 137 135 138 136 static int devman_send_match_ids(int phone, match_id_list_t *match_ids) 139 static int devman_send_match_ids(int phone, match_id_list_t *match_ids) 137 140 { 138 141 link_t *link = match_ids->ids.next; 139 142 match_id_t *match_id = NULL; 140 143 int ret = EOK; 141 144 142 145 while (link != &match_ids->ids) { 143 146 match_id = list_get_instance(link, match_id_t, link); 144 if (EOK != (ret = devman_send_match_id(phone, match_id))) 145 { 146 printf("Driver failed to send match id, error number = %d\n", ret); 147 return ret; 148 } 147 ret = devman_send_match_id(phone, match_id); 148 if (ret != EOK) { 149 printf("Driver failed to send match id, error %d\n", 150 ret); 151 return ret; 152 } 153 149 154 link = link->next; 150 155 } 151 return ret; 152 } 153 154 int devman_child_device_register( 155 const char *name, match_id_list_t *match_ids, devman_handle_t parent_handle, devman_handle_t *handle) 156 { 156 157 return ret; 158 } 159 160 /** Add function to a device. 161 * 162 * Request devman to add a new function to the specified device owned by 163 * this driver task. 164 * 165 * @param name Name of the new function 166 * @param ftype Function type, fun_inner or fun_exposed 167 * @param match_ids Match IDs (should be empty for fun_exposed) 168 * @param devh Devman handle of the device 169 * @param funh Place to store handle of the new function 170 * 171 * @return EOK on success or negative error code. 172 */ 173 int devman_add_function(const char *name, fun_type_t ftype, 174 match_id_list_t *match_ids, devman_handle_t devh, devman_handle_t *funh) 175 { 157 176 int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING); 177 int fun_handle; 158 178 159 179 if (phone < 0) … … 162 182 async_serialize_start(); 163 183 164 int match_count = list_count(&match_ids->ids); 165 ipc_call_t answer; 166 aid_t req = async_send_2(phone, DEVMAN_ADD_CHILD_DEVICE, parent_handle, match_count, &answer); 184 int match_count = list_count(&match_ids->ids); 185 ipc_call_t answer; 186 187 aid_t req = async_send_3(phone, DEVMAN_ADD_FUNCTION, (sysarg_t) ftype, 188 devh, match_count, &answer); 167 189 168 190 sysarg_t retval = async_data_write_start(phone, name, str_size(name)); … … 179 201 async_serialize_end(); 180 202 181 if (retval != EOK) { 182 if (handle != NULL) { 183 *handle = -1; 184 } 185 return retval; 186 } 187 188 if (handle != NULL) 189 *handle = (int) IPC_GET_ARG1(answer); 190 191 return retval; 192 } 193 194 int devman_add_device_to_class(devman_handle_t devman_handle, const char *class_name) 203 if (retval == EOK) 204 fun_handle = (int) IPC_GET_ARG1(answer); 205 else 206 fun_handle = -1; 207 208 *funh = fun_handle; 209 210 return retval; 211 } 212 213 int devman_add_device_to_class(devman_handle_t devman_handle, 214 const char *class_name) 195 215 { 196 216 int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING); … … 201 221 async_serialize_start(); 202 222 ipc_call_t answer; 203 aid_t req = async_send_1(phone, DEVMAN_ADD_DEVICE_TO_CLASS, devman_handle, &answer); 204 205 sysarg_t retval = async_data_write_start(phone, class_name, str_size(class_name)); 223 aid_t req = async_send_1(phone, DEVMAN_ADD_DEVICE_TO_CLASS, 224 devman_handle, &answer); 225 226 sysarg_t retval = async_data_write_start(phone, class_name, 227 str_size(class_name)); 206 228 if (retval != EOK) { 207 229 async_wait_for(req, NULL); … … 213 235 async_serialize_end(); 214 236 215 return retval; 237 return retval; 216 238 } 217 239 … … 221 243 case DEVMAN_DRIVER: 222 244 if (devman_phone_driver >= 0) { 223 ipc_hangup(devman_phone_driver);245 async_hangup(devman_phone_driver); 224 246 devman_phone_driver = -1; 225 247 } … … 227 249 case DEVMAN_CLIENT: 228 250 if (devman_phone_client >= 0) { 229 ipc_hangup(devman_phone_client);251 async_hangup(devman_phone_client); 230 252 devman_phone_client = -1; 231 253 } … … 266 288 } 267 289 268 int devman_device_get_handle(const char *pathname, devman_handle_t *handle, unsigned int flags) 290 int devman_device_get_handle(const char *pathname, devman_handle_t *handle, 291 unsigned int flags) 269 292 { 270 293 int phone = devman_get_phone(DEVMAN_CLIENT, flags); … … 279 302 &answer); 280 303 281 sysarg_t retval = async_data_write_start(phone, pathname, str_size(pathname)); 304 sysarg_t retval = async_data_write_start(phone, pathname, 305 str_size(pathname)); 282 306 if (retval != EOK) { 283 307 async_wait_for(req, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.