Changes in / [eaa0c3f:86c71de] in mainline
- Location:
- uspace
- Files:
-
- 30 edited
-
app/trace/trace.c (modified) (1 diff)
-
drv/char/ps2mouse/ps2mouse.c (modified) (4 diffs)
-
drv/char/ps2mouse/ps2mouse.h (modified) (1 diff)
-
drv/char/xtkbd/xtkbd.c (modified) (3 diffs)
-
drv/char/xtkbd/xtkbd.h (modified) (1 diff)
-
lib/c/include/ipc/devman.h (modified) (1 diff)
-
lib/c/include/ipc/net.h (modified) (1 diff)
-
lib/c/include/ipc/net_net.h (modified) (1 diff)
-
lib/drv/generic/driver.c (modified) (2 diffs)
-
lib/drv/include/ddf/driver.h (modified) (1 diff)
-
lib/net/generic/net_remote.c (modified) (1 diff)
-
lib/net/include/net_interface.h (modified) (1 diff)
-
lib/net/include/nil_remote.h (modified) (1 diff)
-
lib/net/nil/nil_remote.c (modified) (2 diffs)
-
lib/nic/include/nic.h (modified) (1 diff)
-
lib/nic/include/nic_driver.h (modified) (1 diff)
-
lib/nic/src/nic_driver.c (modified) (7 diffs)
-
lib/nic/src/nic_impl.c (modified) (2 diffs)
-
srv/devman/devman.c (modified) (2 diffs)
-
srv/loc/loc.c (modified) (8 diffs)
-
srv/net/cfg/e1k.nic (modified) (1 diff)
-
srv/net/cfg/lo.nic (modified) (1 diff)
-
srv/net/cfg/ne2k.nic (modified) (1 diff)
-
srv/net/net/Makefile (modified) (1 diff)
-
srv/net/net/net.c (modified) (12 diffs)
-
srv/net/net/net.h (modified) (3 diffs)
-
srv/net/nil/eth/eth.c (modified) (7 diffs)
-
srv/net/nil/eth/eth.h (modified) (2 diffs)
-
srv/net/nil/nildummy/nildummy.c (modified) (5 diffs)
-
srv/net/nil/nildummy/nildummy.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/trace/trace.c
reaa0c3f r86c71de 623 623 error: 624 624 loader_abort(ldr); 625 free(ldr); 625 626 return NULL; 626 627 } -
uspace/drv/char/ps2mouse/ps2mouse.c
reaa0c3f r86c71de 116 116 assert(mouse); 117 117 assert(dev); 118 mouse-> client_sess = NULL;118 mouse->input_sess = NULL; 119 119 mouse->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE, 120 120 dev->handle, IPC_FLAG_BLOCKING); … … 218 218 219 219 async_exch_t *exch = 220 async_exchange_begin(mouse-> client_sess);220 async_exchange_begin(mouse->input_sess); 221 221 if (!exch) { 222 222 ddf_msg(LVL_ERROR, 223 "Failed creatingexchange.");223 "Failed to create input exchange."); 224 224 continue; 225 225 } … … 277 277 278 278 async_exch_t *exch = 279 async_exchange_begin(mouse-> client_sess);279 async_exchange_begin(mouse->input_sess); 280 280 if (!exch) { 281 281 ddf_msg(LVL_ERROR, 282 "Failed creatingexchange.");282 "Failed to create input exchange."); 283 283 continue; 284 284 } … … 386 386 if (sess == NULL) { 387 387 ddf_msg(LVL_WARN, 388 "Failed creating client callbacksession");388 "Failed to create start input session"); 389 389 async_answer_0(icallid, EAGAIN); 390 390 break; 391 391 } 392 if (mouse-> client_sess == NULL) {393 mouse-> client_sess = sess;394 ddf_msg(LVL_DEBUG, "Set client session");392 if (mouse->input_sess == NULL) { 393 mouse->input_sess = sess; 394 ddf_msg(LVL_DEBUG, "Set input session"); 395 395 async_answer_0(icallid, EOK); 396 396 } else { 397 ddf_msg(LVL_ERROR, " Client session already set");397 ddf_msg(LVL_ERROR, "Input session already set"); 398 398 async_answer_0(icallid, ELIMIT); 399 399 } -
uspace/drv/char/ps2mouse/ps2mouse.h
reaa0c3f r86c71de 43 43 ddf_fun_t *mouse_fun; /**< Mouse function. */ 44 44 async_sess_t *parent_sess; /**< Connection to device providing data. */ 45 async_sess_t * client_sess; /**< Callback connection to client. */45 async_sess_t *input_sess; /**< Callback connection to consumer. */ 46 46 fid_t polling_fibril; /**< Fibril retrieving an parsing data. */ 47 47 } ps2_mouse_t; -
uspace/drv/char/xtkbd/xtkbd.c
reaa0c3f r86c71de 206 206 assert(kbd); 207 207 assert(dev); 208 kbd-> client_sess = NULL;208 kbd->input_sess = NULL; 209 209 kbd->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE, 210 210 dev->handle, IPC_FLAG_BLOCKING); … … 296 296 if (key != 0) { 297 297 async_exch_t *exch = 298 async_exchange_begin(kbd-> client_sess);298 async_exchange_begin(kbd->input_sess); 299 299 if (!exch) { 300 300 ddf_msg(LVL_ERROR, 301 "Failed creatingexchange.");301 "Failed to create input exchange."); 302 302 continue; 303 303 } … … 352 352 if (sess == NULL) { 353 353 ddf_msg(LVL_WARN, 354 "Failed creating callbacksession");354 "Failed to create start input session"); 355 355 async_answer_0(icallid, EAGAIN); 356 356 break; 357 357 } 358 if (kbd-> client_sess == NULL) {359 kbd-> client_sess = sess;360 ddf_msg(LVL_DEBUG, "Set client session");358 if (kbd->input_sess == NULL) { 359 kbd->input_sess = sess; 360 ddf_msg(LVL_DEBUG, "Set input session"); 361 361 async_answer_0(icallid, EOK); 362 362 } else { 363 ddf_msg(LVL_ERROR, " Client session already set");363 ddf_msg(LVL_ERROR, "Input session already set"); 364 364 async_answer_0(icallid, ELIMIT); 365 365 } -
uspace/drv/char/xtkbd/xtkbd.h
reaa0c3f r86c71de 43 43 ddf_fun_t *kbd_fun; /**< Keyboard function. */ 44 44 async_sess_t *parent_sess; /**< Connection to device providing data. */ 45 async_sess_t * client_sess; /**< Callback connection to client. */45 async_sess_t *input_sess; /**< Callback connection to consumer. */ 46 46 fid_t polling_fibril; /**< Fibril retrieving an parsing data. */ 47 47 } xt_kbd_t; -
uspace/lib/c/include/ipc/devman.h
reaa0c3f r86c71de 146 146 typedef enum { 147 147 DRIVER_DEV_ADD = IPC_FIRST_USER_METHOD, 148 DRIVER_DEV_ADDED, 148 149 DRIVER_DEV_REMOVE, 149 150 DRIVER_DEV_GONE, -
uspace/lib/c/include/ipc/net.h
reaa0c3f r86c71de 305 305 * 306 306 */ 307 #define IPC_GET_DEVICE_HANDLE(call) (( service_id_t) IPC_GET_ARG2(call))307 #define IPC_GET_DEVICE_HANDLE(call) ((devman_handle_t) IPC_GET_ARG2(call)) 308 308 309 309 /** Return the device driver service message argument. -
uspace/lib/c/include/ipc/net_net.h
reaa0c3f r86c71de 54 54 NET_NET_GET_DEVICES_COUNT, 55 55 /** Return names and device IDs of all devices */ 56 NET_NET_GET_DEVICES 56 NET_NET_GET_DEVICES, 57 /** Notify the networking service about a ready device */ 58 NET_NET_DRIVER_READY 57 59 } net_messages; 58 60 -
uspace/lib/drv/generic/driver.c
reaa0c3f r86c71de 303 303 } 304 304 305 static void driver_dev_added(ipc_callid_t iid, ipc_call_t *icall) 306 { 307 fibril_mutex_lock(&devices_mutex); 308 ddf_dev_t *dev = driver_get_device(IPC_GET_ARG1(*icall)); 309 fibril_mutex_unlock(&devices_mutex); 310 311 if (dev != NULL && driver->driver_ops->device_added != NULL) 312 driver->driver_ops->device_added(dev); 313 } 314 305 315 static void driver_dev_remove(ipc_callid_t iid, ipc_call_t *icall) 306 316 { … … 450 460 case DRIVER_DEV_ADD: 451 461 driver_dev_add(callid, &call); 462 break; 463 case DRIVER_DEV_ADDED: 464 async_answer_0(callid, EOK); 465 driver_dev_added(callid, &call); 452 466 break; 453 467 case DRIVER_DEV_REMOVE: -
uspace/lib/drv/include/ddf/driver.h
reaa0c3f r86c71de 145 145 /** Ask driver to offline a specific function */ 146 146 int (*fun_offline)(ddf_fun_t *); 147 148 /** 149 * Notification that the device was succesfully added. 150 * The driver can do any blocking operation without 151 * blocking the device manager. 152 * 153 * XXX REMOVE THIS 154 */ 155 void (*device_added)(ddf_dev_t *dev); 147 156 } driver_ops_t; 148 157 -
uspace/lib/net/generic/net_remote.c
reaa0c3f r86c71de 167 167 } 168 168 169 int net_driver_ready(async_sess_t *sess, devman_handle_t handle) 170 { 171 async_exch_t *exch = async_exchange_begin(sess); 172 int rc = async_req_1_0(exch, NET_NET_DRIVER_READY, handle); 173 async_exchange_end(exch); 174 175 return rc; 176 } 177 169 178 /** @} 170 179 */ -
uspace/lib/net/include/net_interface.h
reaa0c3f r86c71de 52 52 extern int net_get_devices_req(async_sess_t *, measured_string_t **, size_t *, 53 53 uint8_t **); 54 extern int net_driver_ready(async_sess_t *, devman_handle_t); 54 55 extern async_sess_t *net_connect_module(void); 55 56 -
uspace/lib/net/include/nil_remote.h
reaa0c3f r86c71de 34 34 #define __NET_NIL_REMOTE_H__ 35 35 36 #include <ipc/loc.h>37 36 #include <net/device.h> 38 37 #include <net/packet.h> -
uspace/lib/net/nil/nil_remote.c
reaa0c3f r86c71de 36 36 */ 37 37 38 #include <ipc/loc.h>39 38 #include <nil_remote.h> 40 39 #include <generic.h> … … 124 123 125 124 int nil_device_req(async_sess_t *sess, nic_device_id_t device_id, 126 service_id_t sid, size_t mtu)125 devman_handle_t handle, size_t mtu) 127 126 { 128 127 async_exch_t *exch = async_exchange_begin(sess); 129 128 int rc = async_req_3_0(exch, NET_NIL_DEVICE, (sysarg_t) device_id, 130 (sysarg_t) sid, (sysarg_t) mtu);129 (sysarg_t) handle, (sysarg_t) mtu); 131 130 async_exchange_end(exch); 132 131 return rc; -
uspace/lib/nic/include/nic.h
reaa0c3f r86c71de 219 219 extern void nic_set_poll_handlers(nic_t *, 220 220 poll_mode_change_handler, poll_request_handler); 221 222 /* Functions called in device_added */ 223 extern int nic_ready(nic_t *); 221 224 222 225 /* General driver functions */ -
uspace/lib/nic/include/nic_driver.h
reaa0c3f r86c71de 80 80 /** Device's default MAC address (assigned the first time, used in STOP) */ 81 81 nic_address_t default_mac; 82 /** Session to SERVICE_NETWORKING */ 83 async_sess_t *net_session; 82 84 /** Session to SERVICE_ETHERNET or SERVICE_NILDUMMY */ 83 85 async_sess_t *nil_session; -
uspace/lib/nic/src/nic_driver.c
reaa0c3f r86c71de 49 49 #include <devman.h> 50 50 #include <ddf/interrupt.h> 51 #include <net_interface.h> 51 52 #include <ops/nic.h> 52 53 #include <errno.h> … … 88 89 nic_iface_t *iface) 89 90 { 91 if (driver_ops) { 92 if (!driver_ops->device_added) 93 driver_ops->device_added = nic_device_added_impl; 94 } 95 90 96 if (dev_ops) { 91 97 if (!dev_ops->open) … … 423 429 424 430 /** 425 * Connect to IRC service. This function should be called only from431 * Connect to the NET and IRQ services. This function should be called only from 426 432 * the add_device handler, thus no locking is required. 427 433 * … … 430 436 * @return EOK If connection was successful. 431 437 * @return EINVAL If the IRC service cannot be determined. 432 * @return EREFUSED If IRC service cannot be connected.438 * @return EREFUSED If NET or IRC service cannot be connected. 433 439 */ 434 440 int nic_connect_to_services(nic_t *nic_data) 435 441 { 442 /* NET service */ 443 nic_data->net_session = service_connect_blocking(EXCHANGE_SERIALIZE, 444 SERVICE_NETWORKING, 0, 0); 445 if (nic_data->net_session == NULL) 446 return errno; 447 436 448 /* IRC service */ 437 449 sysarg_t apic; … … 450 462 451 463 return EOK; 464 } 465 466 /** Notify the NET service that the device is ready 467 * 468 * @param nic NICF structure 469 * 470 * @return EOK on success 471 * 472 */ 473 int nic_ready(nic_t *nic) 474 { 475 fibril_rwlock_read_lock(&nic->main_lock); 476 477 async_sess_t *session = nic->net_session; 478 devman_handle_t handle = nic->dev->handle; 479 480 fibril_rwlock_read_unlock(&nic->main_lock); 481 482 if (session == NULL) 483 return EINVAL; 484 485 return net_driver_ready(session, handle); 452 486 } 453 487 … … 692 726 nic_data->device_id = NIC_DEVICE_INVALID_ID; 693 727 nic_data->state = NIC_STATE_STOPPED; 728 nic_data->net_session = NULL; 694 729 nic_data->nil_session = NULL; 695 730 nic_data->irc_session = NULL; … … 746 781 */ 747 782 static void nic_destroy(nic_t *nic_data) { 783 if (nic_data->net_session != NULL) { 784 async_hangup(nic_data->net_session); 785 } 786 748 787 if (nic_data->nil_session != NULL) { 749 788 async_hangup(nic_data->nil_session); -
uspace/lib/nic/src/nic_impl.c
reaa0c3f r86c71de 85 85 } 86 86 if (state == NIC_STATE_ACTIVE) { 87 if (nic_data->nil_session == NULL || nic_data->device_id < 0) { 87 if (nic_data->nil_session == NULL || nic_data->net_session == NULL 88 || nic_data->device_id < 0) { 88 89 fibril_rwlock_write_unlock(&nic_data->main_lock); 89 90 return EINVAL; … … 804 805 } 805 806 807 /** Default implementation of the device_added method 808 * 809 * Just calls nic_ready. 810 * 811 * @param dev 812 * 813 */ 814 void nic_device_added_impl(ddf_dev_t *dev) 815 { 816 nic_ready((nic_t *) dev->driver_data); 817 } 818 806 819 /** 807 820 * Default handler for unknown methods (outside of the NIC interface). -
uspace/srv/devman/devman.c
reaa0c3f r86c71de 794 794 case EOK: 795 795 dev->state = DEVICE_USABLE; 796 exch = async_exchange_begin(drv->sess); 797 async_msg_1(exch, DRIVER_DEV_ADDED, dev->handle); 798 async_exchange_end(exch); 796 799 break; 797 800 case ENOENT: … … 800 803 default: 801 804 dev->state = DEVICE_INVALID; 802 break;803 805 } 804 806 -
uspace/srv/loc/loc.c
reaa0c3f r86c71de 56 56 #define NULL_SERVICES 256 57 57 58 /** Callback session */59 typedef struct {60 link_t cb_sess_list;61 async_sess_t *sess;62 } cb_sess_t;63 64 58 LIST_INITIALIZE(services_list); 65 59 LIST_INITIALIZE(namespaces_list); … … 92 86 93 87 static FIBRIL_MUTEX_INITIALIZE(callback_sess_mutex); 94 static LIST_INITIALIZE(callback_sess_list);88 static async_sess_t *callback_sess = NULL; 95 89 96 90 service_id_t loc_create_id(void) … … 614 608 size_t act_size; 615 609 loc_service_t *svc; 616 char *fqn;617 610 618 611 if (!async_data_read_receive(&callid, &size)) { … … 632 625 } 633 626 634 if (asprintf(&fqn, "%s/%s", svc->namespace->name, svc->name) < 0) { 635 fibril_mutex_unlock(&services_list_mutex); 636 async_answer_0(callid, ENOMEM); 637 async_answer_0(iid, ENOMEM); 638 return; 639 } 640 641 act_size = str_size(fqn); 627 act_size = str_size(svc->name); 642 628 if (act_size > size) { 643 free(fqn);644 629 fibril_mutex_unlock(&services_list_mutex); 645 630 async_answer_0(callid, EOVERFLOW); … … 648 633 } 649 634 650 sysarg_t retval = async_data_read_finalize(callid, fqn,635 sysarg_t retval = async_data_read_finalize(callid, svc->name, 651 636 min(size, act_size)); 652 free(fqn);653 637 654 638 fibril_mutex_unlock(&services_list_mutex); … … 806 790 } 807 791 808 /** Create callback connection. 809 * 810 * Create callback connection which will be used to send category change 811 * events. 812 * 813 * On success, answer will contain EOK int retval. 792 /** Find ID for category specified by name. 793 * 794 * On success, answer will contain EOK int retval and service ID in arg1. 814 795 * On failure, error code will be sent in retval. 796 * 815 797 */ 816 798 static void loc_callback_create(ipc_callid_t iid, ipc_call_t *icall) 817 799 { 818 cb_sess_t *cb_sess; 819 820 cb_sess = calloc(1, sizeof(cb_sess_t)); 800 async_sess_t *cb_sess = async_callback_receive(EXCHANGE_SERIALIZE); 821 801 if (cb_sess == NULL) { 822 802 async_answer_0(iid, ENOMEM); … … 824 804 } 825 805 826 async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE);827 if (sess == NULL) {828 free(cb_sess);829 async_answer_0(iid, ENOMEM);830 return;831 }832 833 cb_sess->sess = sess;834 link_initialize(&cb_sess->cb_sess_list);835 836 806 fibril_mutex_lock(&callback_sess_mutex); 837 list_append(&cb_sess->cb_sess_list, &callback_sess_list); 807 if (callback_sess != NULL) { 808 fibril_mutex_unlock(&callback_sess_mutex); 809 async_answer_0(iid, EEXIST); 810 return; 811 } 812 813 callback_sess = cb_sess; 838 814 fibril_mutex_unlock(&callback_sess_mutex); 839 815 … … 844 820 { 845 821 fibril_mutex_lock(&callback_sess_mutex); 846 847 list_foreach(callback_sess_list, link) { 848 cb_sess_t *cb_sess; 849 850 cb_sess = list_get_instance(link, cb_sess_t, cb_sess_list); 851 852 async_exch_t *exch = async_exchange_begin(cb_sess->sess); 822 823 if (callback_sess != NULL) { 824 async_exch_t *exch = async_exchange_begin(callback_sess); 853 825 async_msg_0(exch, LOC_EVENT_CAT_CHANGE); 854 826 async_exchange_end(exch); 855 827 } 856 828 857 829 fibril_mutex_unlock(&callback_sess_mutex); 858 830 } -
uspace/srv/net/cfg/e1k.nic
reaa0c3f r86c71de 3 3 NAME=e1k 4 4 5 HWPATH= devices/\hw\pci0\00:03.0\port05 HWPATH=/hw/pci0/00:03.0/port0 6 6 NIL=eth 7 7 IL=ip -
uspace/srv/net/cfg/lo.nic
reaa0c3f r86c71de 3 3 NAME=lo 4 4 5 HWPATH= devices/\virt\lo\port05 HWPATH=/virt/lo/port0 6 6 NIL=nildummy 7 7 IL=ip -
uspace/srv/net/cfg/ne2k.nic
reaa0c3f r86c71de 3 3 NAME=ne2k 4 4 5 HWPATH= devices/\hw\pci0\00:01.0\ne2k\port05 HWPATH=/hw/pci0/00:01.0/ne2k/port0 6 6 NIL=eth 7 7 IL=ip -
uspace/srv/net/net/Makefile
reaa0c3f r86c71de 31 31 ROOT_PATH = $(USPACE_PREFIX)/.. 32 32 LIBS = $(LIBNET_PREFIX)/libnet.a 33 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include -I$(LIBNIC_PREFIX)/include \ 34 -I$(LIBDRV_PREFIX)/include 33 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include 35 34 36 35 COMMON_MAKEFILE = $(ROOT_PATH)/Makefile.common -
uspace/srv/net/net/net.c
reaa0c3f r86c71de 41 41 #include <stdio.h> 42 42 #include <str.h> 43 #include <devman.h> 43 44 #include <str_error.h> 44 45 #include <ns.h> … … 55 56 #include <adt/measured_strings.h> 56 57 #include <adt/module_map.h> 57 #include <loc.h>58 #include <nic.h>59 58 #include <nil_remote.h> 60 59 #include <net_interface.h> … … 74 73 GENERIC_CHAR_MAP_IMPLEMENT(measured_strings, measured_string_t); 75 74 DEVICE_MAP_IMPLEMENT(netifs, netif_t); 76 LIST_INITIALIZE(netif_list);77 75 78 76 /** Add the configured setting to the configuration map. … … 289 287 * 290 288 */ 291 static int init_device(netif_t *netif, service_id_t sid)289 static int init_device(netif_t *netif, devman_handle_t handle) 292 290 { 293 291 printf("%s: Initializing device '%s'\n", NAME, netif->name); 294 292 295 link_initialize(&netif->netif_list); 296 297 netif->sid = sid; 298 netif->sess = loc_service_connect(EXCHANGE_SERIALIZE, netif->sid, 293 netif->handle = handle; 294 netif->sess = devman_device_connect(EXCHANGE_SERIALIZE, netif->handle, 299 295 IPC_FLAG_BLOCKING); 300 296 if (netif->sess == NULL) { … … 341 337 strtol((const char *) setting->value, NULL, 10) : 0; 342 338 rc = nil_device_req(netif->nil->sess, netif->id, 343 netif-> sid, mtu);339 netif->handle, mtu); 344 340 if (rc != EOK) { 345 341 printf("%s: Unable to start network interface layer\n", … … 367 363 368 364 printf("%s: Activating device '%s'\n", NAME, netif->name); 369 list_append(&netif->netif_list, &netif_list);370 365 return nic_set_state(netif->sess, NIC_STATE_ACTIVE); 371 366 } 372 367 373 static int net_nic_ready(service_id_t sid) 374 { 375 int rc; 376 char *hwpath; 377 378 rc = loc_service_get_name(sid, &hwpath); 379 if (rc != EOK) { 380 printf("%s: Failed getting name of service '%u'\n", 381 NAME, (unsigned) sid); 368 static int net_port_ready(devman_handle_t handle) 369 { 370 char hwpath[MAX_PATH_LENGTH]; 371 int rc = devman_fun_get_path(handle, hwpath, MAX_PATH_LENGTH); 372 if (rc != EOK) 382 373 return EINVAL; 383 }384 374 385 375 int index = char_map_find(&net_globals.netif_hwpaths, 386 376 (uint8_t *) hwpath, 0); 387 388 if (index == CHAR_MAP_NULL) { 389 printf("%s: Service '%s' not found in map.\n", NAME, hwpath); 390 free(hwpath); 377 if (index == CHAR_MAP_NULL) 391 378 return ENOENT; 392 }393 394 free(hwpath);395 379 396 380 netif_t *netif = netifs_get_index(&net_globals.netifs, index); … … 398 382 return ENOENT; 399 383 400 rc = init_device(netif, sid);384 rc = init_device(netif, handle); 401 385 if (rc != EOK) 402 386 return rc; … … 407 391 408 392 netif->il->usage++; 393 394 return EOK; 395 } 396 397 static int net_driver_ready_local(devman_handle_t handle) 398 { 399 devman_handle_t *funs; 400 size_t count; 401 int rc = devman_dev_get_functions(handle, &funs, &count); 402 if (rc != EOK) 403 return rc; 404 405 for (size_t i = 0; i < count; i++) { 406 rc = net_port_ready(funs[i]); 407 if (rc != EOK) 408 return rc; 409 } 409 410 410 411 return EOK; … … 478 479 net_free_devices(strings, count); 479 480 return rc; 481 case NET_NET_DRIVER_READY: 482 rc = net_driver_ready_local(IPC_GET_ARG1(*call)); 483 *answer_count = 0; 484 return rc; 480 485 default: 481 486 return ENOTSUP; … … 523 528 answer_call(callid, res, &answer, count); 524 529 } 525 }526 527 static int nic_check_new(void)528 {529 category_id_t nic_cat;530 service_id_t *svcs;531 size_t count, i;532 bool already_known;533 int rc;534 535 rc = loc_category_get_id(DEVICE_CATEGORY_NIC, &nic_cat, IPC_FLAG_BLOCKING);536 if (rc != EOK) {537 printf("%s: Failed resolving category '%s'.\n", NAME,538 DEVICE_CATEGORY_NIC);539 return ENOENT;540 }541 542 rc = loc_category_get_svcs(nic_cat, &svcs, &count);543 if (rc != EOK) {544 printf("%s: Failed getting list of NIC devices.\n", NAME);545 return EIO;546 }547 548 for (i = 0; i < count; i++) {549 already_known = false;550 551 list_foreach(netif_list, link) {552 netif_t *netif = list_get_instance(link, netif_t, netif_list);553 if (netif->sid == svcs[i]) {554 already_known = true;555 break;556 }557 }558 559 if (!already_known) {560 rc = net_nic_ready(svcs[i]);561 if (rc != EOK) {562 printf("%s: Failed adding NIC device #%u.\n",563 NAME, (unsigned) svcs[i]);564 }565 }566 }567 568 free(svcs);569 return EOK;570 }571 572 static void cat_change_cb(void)573 {574 (void) nic_check_new();575 }576 577 static int net_start_nic_discovery(void)578 {579 int rc;580 581 rc = loc_register_cat_change_cb(cat_change_cb);582 if (rc != EOK) {583 printf("%s: Failed registering callback for device discovery (%d).\n",584 NAME, rc);585 return rc;586 }587 588 return nic_check_new();589 530 } 590 531 … … 632 573 continue; 633 574 634 netif-> sid= -1;575 netif->handle = -1; 635 576 netif->sess = NULL; 636 577 … … 756 697 } 757 698 758 rc = net_start_nic_discovery();759 if (rc != EOK) {760 printf("%s: Error starting NIC discovery\n", NAME);761 pm_destroy();762 return rc;763 }764 765 699 task_retval(0); 766 700 async_manager(); -
uspace/srv/net/net/net.h
reaa0c3f r86c71de 35 35 #define NET_NET_H_ 36 36 37 #include <ipc/loc.h>38 37 #include <net/device.h> 39 38 #include <adt/char_map.h> … … 42 41 #include <adt/module_map.h> 43 42 #include <net/packet.h> 43 #include <devman.h> 44 44 45 45 #define NAME "net" … … 96 96 97 97 /** Serving network interface driver module index. */ 98 service_id_t sid; /**< Service ID*/98 devman_handle_t handle; /**< Handle for devman */ 99 99 async_sess_t *sess; /**< Driver session. */ 100 100 101 101 module_t *nil; /**< Serving link layer module index. */ 102 102 module_t *il; /**< Serving internet layer module index. */ 103 104 link_t netif_list;105 103 } netif_t; 106 104 -
uspace/srv/net/nil/eth/eth.c
reaa0c3f r86c71de 48 48 #include <ipc/net.h> 49 49 #include <ipc/services.h> 50 #include <loc.h>51 50 #include <net/modules.h> 52 51 #include <net_checksum.h> … … 227 226 * 228 227 * @param[in] device_id New device identifier. 229 * @param[in] sid NIC service ID.228 * @param[in] handle Device driver handle. 230 229 * @param[in] mtu Device maximum transmission unit. 231 230 * … … 235 234 * 236 235 */ 237 static int eth_device_message(nic_device_id_t device_id, service_id_t sid,236 static int eth_device_message(nic_device_id_t device_id, devman_handle_t handle, 238 237 size_t mtu) 239 238 { … … 260 259 device = eth_devices_find(ð_globals.devices, device_id); 261 260 if (device) { 262 if (device-> sid != sid) {261 if (device->handle != handle) { 263 262 printf("Device %d already exists\n", device->device_id); 264 263 fibril_rwlock_write_unlock(ð_globals.devices_lock); … … 299 298 300 299 device->device_id = device_id; 301 device-> sid = sid;300 device->handle = handle; 302 301 device->flags = 0; 303 302 if ((mtu > 0) && (mtu <= ETH_MAX_TAGGED_CONTENT(device->flags))) … … 336 335 337 336 /* Bind the device driver */ 338 device->sess = loc_service_connect(EXCHANGE_SERIALIZE, sid,337 device->sess = devman_device_connect(EXCHANGE_SERIALIZE, handle, 339 338 IPC_FLAG_BLOCKING); 340 339 if (device->sess == NULL) { … … 363 362 } 364 363 365 printf("%s: Device registered (id: %d, sid: %zu: mtu: %zu, "364 printf("%s: Device registered (id: %d, handle: %zu: mtu: %zu, " 366 365 "mac: " PRIMAC ", flags: 0x%x)\n", NAME, 367 device->device_id, device-> sid, device->mtu,366 device->device_id, device->handle, device->mtu, 368 367 ARGSMAC(device->addr.address), device->flags); 369 368 -
uspace/srv/net/nil/eth/eth.h
reaa0c3f r86c71de 41 41 #include <async.h> 42 42 #include <fibril_synch.h> 43 #include <ipc/loc.h>44 43 #include <ipc/services.h> 45 44 #include <net/device.h> 46 45 #include <adt/measured_strings.h> 46 #include <devman.h> 47 47 48 48 /** Ethernet address length. */ … … 224 224 nic_device_id_t device_id; 225 225 /** Device handle */ 226 service_id_t sid;226 devman_handle_t handle; 227 227 /** Driver session. */ 228 228 async_sess_t *sess; -
uspace/srv/net/nil/nildummy/nildummy.c
reaa0c3f r86c71de 53 53 #include <packet_remote.h> 54 54 #include <packet_client.h> 55 #include <devman.h> 55 56 #include <device/nic.h> 56 #include <loc.h>57 57 #include <nil_skel.h> 58 58 #include "nildummy.h" … … 115 115 */ 116 116 static int nildummy_device_message(nic_device_id_t device_id, 117 service_id_t sid, size_t mtu)117 devman_handle_t handle, size_t mtu) 118 118 { 119 119 fibril_rwlock_write_lock(&nildummy_globals.devices_lock); … … 123 123 nildummy_devices_find(&nildummy_globals.devices, device_id); 124 124 if (device) { 125 if (device-> sid != sid) {125 if (device->handle != handle) { 126 126 printf("Device %d exists, handles do not match\n", 127 127 device->device_id); … … 158 158 159 159 device->device_id = device_id; 160 device-> sid = sid;160 device->handle = handle; 161 161 if (mtu > 0) 162 162 device->mtu = mtu; … … 165 165 166 166 /* Bind the device driver */ 167 device->sess = loc_service_connect(EXCHANGE_SERIALIZE, sid,167 device->sess = devman_device_connect(EXCHANGE_SERIALIZE, handle, 168 168 IPC_FLAG_BLOCKING); 169 169 if (device->sess == NULL) { -
uspace/srv/net/nil/nildummy/nildummy.h
reaa0c3f r86c71de 41 41 #include <async.h> 42 42 #include <fibril_synch.h> 43 #include <ipc/loc.h>44 43 #include <ipc/services.h> 44 #include <ipc/devman.h> 45 45 #include <net/device.h> 46 46 … … 78 78 /** Device identifier. */ 79 79 nic_device_id_t device_id; 80 /** Device service ID. */81 service_id_t sid;80 /** Device driver handle. */ 81 devman_handle_t handle; 82 82 /** Driver session. */ 83 83 async_sess_t *sess;
Note:
See TracChangeset
for help on using the changeset viewer.
