Changeset cbfece7 in mainline
- Timestamp:
- 2014-07-21T22:10:18Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1f1fa64
- Parents:
- 96e368a (diff), 54a1ca7 (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. - Location:
- uspace
- Files:
-
- 2 added
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nic/nic.c
r96e368a rcbfece7 60 60 printf("\taddr <mac_address> - set MAC address\n"); 61 61 printf("\tspeed <10|100|1000> - set NIC speed\n"); 62 printf("\tduplex <half|full> - set duplex mode\n"); 62 printf("\tduplex <half|full|simplex> - set duplex mode\n"); 63 printf("\tauto - enable autonegotiation\n"); 63 64 } 64 65 … … 206 207 } 207 208 208 printf("[ Service Name]\n");209 printf("[Index]: [Service Name]\n"); 209 210 for (i = 0; i < count; i++) { 210 211 rc = loc_service_get_name(nics[i], &svc_name); … … 320 321 321 322 return nic_set_operation_mode(sess, oldspeed, duplex, oldrole); 323 } 324 325 static int nic_set_autoneg(int i) 326 { 327 async_sess_t *sess; 328 int rc; 329 330 sess = get_nic_by_index(i); 331 if (sess == NULL) { 332 printf("Specified NIC doesn't exist or cannot connect to it.\n"); 333 return EINVAL; 334 } 335 336 rc = nic_autoneg_restart(sess); 337 if (rc != EOK) { 338 printf("Error restarting NIC autonegotiation.\n"); 339 return EIO; 340 } 341 342 return EOK; 322 343 } 323 344 … … 376 397 return nic_set_duplex(index, argv[3]); 377 398 399 if (!str_cmp(argv[2], "auto")) 400 return nic_set_autoneg(index); 401 378 402 } else { 379 403 printf(NAME ": Invalid argument.\n"); -
uspace/drv/audio/sb16/mixer_iface.c
r96e368a rcbfece7 33 33 */ 34 34 35 #include <ddf/driver.h> 35 36 #include <errno.h> 36 37 #include <audio_mixer_iface.h> 37 38 38 39 #include "mixer.h" 40 #include "sb16.h" 41 42 static sb_mixer_t *fun_to_mixer(ddf_fun_t *fun) 43 { 44 sb16_t *sb = (sb16_t *)ddf_dev_data_get(ddf_fun_get_dev(fun)); 45 return &sb->mixer; 46 } 39 47 40 48 static int sb_get_info(ddf_fun_t *fun, const char** name, unsigned *items) 41 49 { 42 assert(fun); 43 const sb_mixer_t *mixer = ddf_fun_data_get(fun); 44 assert(mixer); 50 sb_mixer_t *mixer = fun_to_mixer(fun); 51 45 52 if (name) 46 53 *name = sb_mixer_type_str(mixer->type); … … 54 61 unsigned *max_level) 55 62 { 56 assert(fun); 57 const sb_mixer_t *mixer = ddf_fun_data_get(fun); 58 assert(mixer); 59 return 60 sb_mixer_get_control_item_info(mixer, item, name, max_level); 63 sb_mixer_t *mixer = fun_to_mixer(fun); 64 return sb_mixer_get_control_item_info(mixer, item, name, max_level); 61 65 } 62 66 63 67 static int sb_set_item_level(ddf_fun_t *fun, unsigned item, unsigned value) 64 68 { 65 assert(fun); 66 const sb_mixer_t *mixer = ddf_fun_data_get(fun); 67 assert(mixer); 69 sb_mixer_t *mixer = fun_to_mixer(fun); 68 70 return sb_mixer_set_control_item_value(mixer, item, value); 69 71 } … … 71 73 static int sb_get_item_level(ddf_fun_t *fun, unsigned item, unsigned *value) 72 74 { 73 assert(fun); 74 const sb_mixer_t *mixer = ddf_fun_data_get(fun); 75 assert(mixer); 75 sb_mixer_t *mixer = fun_to_mixer(fun); 76 76 return sb_mixer_get_control_item_value(mixer, item, value); 77 77 } -
uspace/drv/audio/sb16/pcm_iface.c
r96e368a rcbfece7 39 39 40 40 #include "dsp.h" 41 #include "sb16.h" 41 42 42 static inline sb_dsp_t * 43 static inline sb_dsp_t *fun_to_dsp(ddf_fun_t *fun) 43 44 { 44 assert(fun); 45 sb_dsp_t *dsp = ddf_fun_data_get(fun); 46 assert(dsp); 47 return dsp; 45 sb16_t *sb = (sb16_t *)ddf_dev_data_get(ddf_fun_get_dev(fun)); 46 return &sb->dsp; 48 47 } 49 48 -
uspace/drv/audio/sb16/sb16.c
r96e368a rcbfece7 27 27 */ 28 28 29 #define _DDF_DATA_IMPLANT30 31 29 #include <errno.h> 32 30 #include <str_error.h> … … 121 119 return ret; 122 120 } 123 //TODO remove data implant 124 ddf_fun_data_implant(dsp_fun, &sb->dsp); 121 125 122 ddf_fun_set_ops(dsp_fun, &sb_pcm_ops); 126 123 ddf_log_note("Sound blaster DSP (%x.%x) initialized.", … … 131 128 ddf_log_error( 132 129 "Failed to bind PCM function: %s.", str_error(ret)); 133 // TODO implanted data134 130 ddf_fun_destroy(dsp_fun); 135 131 return ret; … … 141 137 str_error(ret)); 142 138 ddf_fun_unbind(dsp_fun); 143 // TODO implanted data144 139 ddf_fun_destroy(dsp_fun); 145 140 return ret; … … 154 149 ddf_log_error("Failed to create mixer function."); 155 150 ddf_fun_unbind(dsp_fun); 156 // TODO implanted data157 151 ddf_fun_destroy(dsp_fun); 158 152 return ENOMEM; … … 163 157 str_error(ret)); 164 158 ddf_fun_unbind(dsp_fun); 165 // TODO implanted data166 159 ddf_fun_destroy(dsp_fun); 167 160 ddf_fun_destroy(mixer_fun); … … 171 164 ddf_log_note("Initialized mixer: %s.", 172 165 sb_mixer_type_str(sb->mixer.type)); 173 ddf_fun_data_implant(mixer_fun, &sb->mixer);174 166 ddf_fun_set_ops(mixer_fun, &sb_mixer_ops); 175 167 … … 178 170 ddf_log_error( 179 171 "Failed to bind mixer function: %s.", str_error(ret)); 180 // TODO implanted data181 172 ddf_fun_destroy(mixer_fun); 182 183 ddf_fun_unbind(dsp_fun); 184 // TODO implanted data 173 ddf_fun_unbind(dsp_fun); 185 174 ddf_fun_destroy(dsp_fun); 186 175 return ret; -
uspace/drv/block/ahci/ahci.c
r96e368a rcbfece7 38 38 #include <device/hw_res_parsed.h> 39 39 #include <pci_dev_iface.h> 40 #include <sysinfo.h> 41 #include <ipc/irc.h> 42 #include <ns.h> 40 #include <irc.h> 43 41 #include <ahci_iface.h> 44 42 #include "ahci.h" … … 129 127 130 128 static void ahci_get_model_name(uint16_t *, char *); 131 static int ahci_enable_interrupt(int);132 129 133 130 static fibril_mutex_t sata_devices_count_lock; … … 1195 1192 } 1196 1193 1197 rc = ahci_enable_interrupt(hw_res_parsed.irqs.irqs[0]);1194 rc = irc_enable_interrupt(hw_res_parsed.irqs.irqs[0]); 1198 1195 if (rc != EOK) { 1199 1196 ddf_msg(LVL_ERROR, "Failed enable interupt."); … … 1315 1312 } 1316 1313 1317 /** Enable interrupt using SERVICE_IRC.1318 *1319 * @param irq Requested irq number.1320 *1321 * @return EOK if succeed, error code otherwise.1322 *1323 */1324 static int ahci_enable_interrupt(int irq)1325 {1326 async_sess_t *irc_sess = NULL;1327 irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE, SERVICE_IRC, 0, 0);1328 if (!irc_sess)1329 return EINTR;1330 1331 async_exch_t *exch = async_exchange_begin(irc_sess);1332 const int rc = async_req_1_0(exch, IRC_ENABLE_INTERRUPT, irq);1333 async_exchange_end(exch);1334 1335 async_hangup(irc_sess);1336 return rc;1337 }1338 1339 1314 /*----------------------------------------------------------------------------*/ 1340 1315 /*-- AHCI Main routine -------------------------------------------------------*/ -
uspace/drv/bus/isa/isa.c
r96e368a rcbfece7 54 54 #include <ipc/irc.h> 55 55 #include <ipc/services.h> 56 #include <sysinfo.h>57 #include <ns.h>58 56 #include <sys/stat.h> 59 #include <ipc/irc.h> 60 #include <ipc/services.h> 61 #include <sysinfo.h> 57 #include <irc.h> 62 58 #include <ns.h> 63 59 … … 120 116 assert(fun); 121 117 122 sysarg_t apic;123 sysarg_t i8259;124 125 async_sess_t *irc_sess = NULL;126 127 if (((sysinfo_get_value("apic", &apic) == EOK) && (apic))128 || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))) {129 irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,130 SERVICE_IRC, 0, 0);131 }132 133 if (!irc_sess)134 return false;135 136 118 const hw_resource_list_t *res = &fun->hw_resources; 137 119 assert(res); 138 120 for (size_t i = 0; i < res->count; ++i) { 139 121 if (res->resources[i].type == INTERRUPT) { 140 const int irq = res->resources[i].res.interrupt.irq; 141 142 async_exch_t *exch = async_exchange_begin(irc_sess); 143 const int rc = 144 async_req_1_0(exch, IRC_ENABLE_INTERRUPT, irq); 145 async_exchange_end(exch); 146 147 if (rc != EOK) { 148 async_hangup(irc_sess); 122 int rc = irc_enable_interrupt( 123 res->resources[i].res.interrupt.irq); 124 125 if (rc != EOK) 149 126 return false; 150 } 151 } 152 } 153 154 async_hangup(irc_sess); 127 } 128 } 129 155 130 return true; 156 131 } -
uspace/drv/bus/pci/pciintel/pci.c
r96e368a rcbfece7 51 51 #include <ddf/log.h> 52 52 #include <ipc/dev_iface.h> 53 #include <ipc/irc.h> 54 #include <ns.h> 55 #include <ipc/services.h> 56 #include <sysinfo.h> 53 #include <irc.h> 57 54 #include <ops/hw_res.h> 58 55 #include <device/hw_res.h> … … 107 104 pci_fun_t *dev_data = pci_fun(fnode); 108 105 109 sysarg_t apic;110 sysarg_t i8259;111 112 async_sess_t *irc_sess = NULL;113 114 if (((sysinfo_get_value("apic", &apic) == EOK) && (apic))115 || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))) {116 irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,117 SERVICE_IRC, 0, 0);118 }119 120 if (!irc_sess)121 return false;122 123 106 size_t i = 0; 124 107 hw_resource_list_t *res = &dev_data->hw_resources; 125 108 for (; i < res->count; i++) { 126 109 if (res->resources[i].type == INTERRUPT) { 127 const int irq = res->resources[i].res.interrupt.irq; 128 129 async_exch_t *exch = async_exchange_begin(irc_sess); 130 const int rc = 131 async_req_1_0(exch, IRC_ENABLE_INTERRUPT, irq); 132 async_exchange_end(exch); 133 134 if (rc != EOK) { 135 async_hangup(irc_sess); 110 int rc = irc_enable_interrupt( 111 res->resources[i].res.interrupt.irq); 112 113 if (rc != EOK) 136 114 return false; 137 }138 115 } 139 116 } 140 117 141 async_hangup(irc_sess);142 118 return true; 143 119 } -
uspace/drv/bus/usb/usbhid/generic/hiddev.c
r96e368a rcbfece7 35 35 */ 36 36 37 /* XXX Fix this */38 #define _DDF_DATA_IMPLANT39 40 37 #include <usb/debug.h> 41 38 #include <usb/classes/classes.h> -
uspace/drv/bus/usb/usbhid/kbd/kbddev.c
r96e368a rcbfece7 34 34 * USB HID keyboard device structure and API. 35 35 */ 36 37 /* XXX Fix this */38 #define _DDF_DATA_IMPLANT39 36 40 37 #include <errno.h> … … 479 476 } 480 477 481 /* HID/KBD structure manipulation */ 482 483 static int usb_kbd_create_function(usb_kbd_t *kbd_dev) 484 { 485 assert(kbd_dev != NULL); 486 assert(kbd_dev->hid_dev != NULL); 487 assert(kbd_dev->hid_dev->usb_dev != NULL); 478 /* API functions */ 479 480 /** 481 * Initialization of the USB/HID keyboard structure. 482 * 483 * This functions initializes required structures from the device's descriptors. 484 * 485 * During initialization, the keyboard is switched into boot protocol, the idle 486 * rate is set to 0 (infinity), resulting in the keyboard only reporting event 487 * when a key is pressed or released. Finally, the LED lights are turned on 488 * according to the default setup of lock keys. 489 * 490 * @note By default, the keyboards is initialized with Num Lock turned on and 491 * other locks turned off. 492 * 493 * @param kbd_dev Keyboard device structure to be initialized. 494 * @param dev DDF device structure of the keyboard. 495 * 496 * @retval EOK if successful. 497 * @retval EINVAL if some parameter is not given. 498 * @return Other value inherited from function usbhid_dev_init(). 499 */ 500 int usb_kbd_init(usb_hid_dev_t *hid_dev, void **data) 501 { 502 ddf_fun_t *fun = NULL; 503 usb_kbd_t *kbd_dev = NULL; 504 usb_hid_report_path_t *path = NULL; 505 bool bound = false; 506 fid_t fid = 0; 507 int rc; 508 509 usb_log_debug("Initializing HID/KBD structure...\n"); 510 511 if (hid_dev == NULL) { 512 usb_log_error( 513 "Failed to init keyboard structure: no structure given.\n"); 514 rc = EINVAL; 515 goto error; 516 } 488 517 489 518 /* Create the exposed function. */ 490 519 usb_log_debug("Creating DDF function %s...\n", HID_KBD_FUN_NAME); 491 ddf_fun_t *fun = ddf_fun_create(kbd_dev->hid_dev->usb_dev->ddf_dev,492 fun_exposed,HID_KBD_FUN_NAME);520 fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed, 521 HID_KBD_FUN_NAME); 493 522 if (fun == NULL) { 494 523 usb_log_error("Could not create DDF function node.\n"); 495 return ENOMEM; 524 rc = ENOMEM; 525 goto error; 496 526 } 497 527 … … 499 529 * to the DDF function. */ 500 530 ddf_fun_set_ops(fun, &kbdops); 501 ddf_fun_data_implant(fun, kbd_dev); 502 503 int rc = ddf_fun_bind(fun); 531 532 kbd_dev = ddf_fun_data_alloc(fun, sizeof(usb_kbd_t)); 533 if (kbd_dev == NULL) { 534 usb_log_error("Failed to allocate KBD device structure.\n"); 535 rc = ENOMEM; 536 goto error; 537 } 538 539 kbd_dev->fun = fun; 540 541 /* Default values */ 542 fibril_mutex_initialize(&kbd_dev->repeat_mtx); 543 kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED; 544 545 /* Store link to HID device */ 546 kbd_dev->hid_dev = hid_dev; 547 548 /* Modifiers and locks */ 549 kbd_dev->mods = DEFAULT_ACTIVE_MODS; 550 551 /* Autorepeat */ 552 kbd_dev->repeat.delay_before = DEFAULT_DELAY_BEFORE_FIRST_REPEAT; 553 kbd_dev->repeat.delay_between = DEFAULT_REPEAT_DELAY; 554 555 // TODO: make more general 556 path = usb_hid_report_path(); 557 if (path == NULL) { 558 usb_log_error("Failed to create kbd report path.\n"); 559 rc = ENOMEM; 560 goto error; 561 } 562 563 rc = usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 564 if (rc != EOK) { 565 usb_log_error("Failed to append item to kbd report path.\n"); 566 goto error; 567 } 568 569 usb_hid_report_path_set_report_id(path, 0); 570 571 kbd_dev->key_count = 572 usb_hid_report_size(&hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT); 573 574 usb_hid_report_path_free(path); 575 path = NULL; 576 577 usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count); 578 579 kbd_dev->keys = calloc(kbd_dev->key_count, sizeof(int32_t)); 580 if (kbd_dev->keys == NULL) { 581 usb_log_error("Failed to allocate key buffer.\n"); 582 rc = ENOMEM; 583 goto error; 584 } 585 586 kbd_dev->keys_old = calloc(kbd_dev->key_count, sizeof(int32_t)); 587 if (kbd_dev->keys_old == NULL) { 588 usb_log_error("Failed to allocate old_key buffer.\n"); 589 rc = ENOMEM; 590 goto error; 591 } 592 593 /* Output report */ 594 kbd_dev->output_size = 0; 595 kbd_dev->output_buffer = usb_hid_report_output(&hid_dev->report, 596 &kbd_dev->output_size, 0); 597 if (kbd_dev->output_buffer == NULL) { 598 usb_log_error("Error creating output report buffer.\n"); 599 rc = ENOMEM; 600 goto error; 601 } 602 603 usb_log_debug("Output buffer size: %zu\n", kbd_dev->output_size); 604 605 kbd_dev->led_path = usb_hid_report_path(); 606 if (kbd_dev->led_path == NULL) { 607 usb_log_error("Failed to create kbd led report path.\n"); 608 rc = ENOMEM; 609 goto error; 610 } 611 612 rc = usb_hid_report_path_append_item( 613 kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0); 614 if (rc != EOK) { 615 usb_log_error("Failed to append to kbd/led report path.\n"); 616 goto error; 617 } 618 619 kbd_dev->led_output_size = usb_hid_report_size( 620 &hid_dev->report, 0, USB_HID_REPORT_TYPE_OUTPUT); 621 622 usb_log_debug("Output report size (in items): %zu\n", 623 kbd_dev->led_output_size); 624 625 kbd_dev->led_data = calloc(kbd_dev->led_output_size, sizeof(int32_t)); 626 if (kbd_dev->led_data == NULL) { 627 usb_log_error("Error creating buffer for LED output report.\n"); 628 rc = ENOMEM; 629 goto error; 630 } 631 632 /* Set LEDs according to initial setup. 633 * Set Idle rate */ 634 usb_kbd_set_led(hid_dev, kbd_dev); 635 636 usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe, 637 hid_dev->usb_dev->interface_no, IDLE_RATE); 638 639 /* Create new fibril for auto-repeat. */ 640 fid = fibril_create(usb_kbd_repeat_fibril, kbd_dev); 641 if (fid == 0) { 642 usb_log_error("Failed to start fibril for KBD auto-repeat"); 643 rc = ENOMEM; 644 goto error; 645 } 646 647 kbd_dev->initialized = USB_KBD_STATUS_INITIALIZED; 648 usb_log_debug("HID/KBD device structure initialized.\n"); 649 650 rc = ddf_fun_bind(fun); 504 651 if (rc != EOK) { 505 652 usb_log_error("Could not bind DDF function: %s.\n", 506 653 str_error(rc)); 507 ddf_fun_destroy(fun); 508 return rc; 509 } 654 goto error; 655 } 656 657 bound = true; 510 658 511 659 usb_log_debug("%s function created. Handle: %" PRIun "\n", … … 519 667 "Could not add DDF function to category %s: %s.\n", 520 668 HID_KBD_CATEGORY, str_error(rc)); 521 if (ddf_fun_unbind(fun) == EOK) { 522 ddf_fun_destroy(fun); 523 } else { 524 usb_log_error( 525 "Failed to unbind `%s', will not destroy.\n", 526 ddf_fun_get_name(fun)); 527 } 528 return rc; 529 } 530 kbd_dev->fun = fun; 531 532 return EOK; 533 } 534 535 /* API functions */ 536 537 /** 538 * Initialization of the USB/HID keyboard structure. 539 * 540 * This functions initializes required structures from the device's descriptors. 541 * 542 * During initialization, the keyboard is switched into boot protocol, the idle 543 * rate is set to 0 (infinity), resulting in the keyboard only reporting event 544 * when a key is pressed or released. Finally, the LED lights are turned on 545 * according to the default setup of lock keys. 546 * 547 * @note By default, the keyboards is initialized with Num Lock turned on and 548 * other locks turned off. 549 * 550 * @param kbd_dev Keyboard device structure to be initialized. 551 * @param dev DDF device structure of the keyboard. 552 * 553 * @retval EOK if successful. 554 * @retval EINVAL if some parameter is not given. 555 * @return Other value inherited from function usbhid_dev_init(). 556 */ 557 int usb_kbd_init(usb_hid_dev_t *hid_dev, void **data) 558 { 559 usb_log_debug("Initializing HID/KBD structure...\n"); 560 561 if (hid_dev == NULL) { 562 usb_log_error( 563 "Failed to init keyboard structure: no structure given.\n"); 564 return EINVAL; 565 } 566 567 usb_kbd_t *kbd_dev = calloc(1, sizeof(usb_kbd_t)); 568 if (kbd_dev == NULL) { 569 usb_log_error("Failed to allocate KBD device structure.\n"); 570 return ENOMEM; 571 } 572 /* Default values */ 573 fibril_mutex_initialize(&kbd_dev->repeat_mtx); 574 kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED; 575 576 /* Store link to HID device */ 577 kbd_dev->hid_dev = hid_dev; 578 579 /* Modifiers and locks */ 580 kbd_dev->mods = DEFAULT_ACTIVE_MODS; 581 582 /* Autorepeat */ 583 kbd_dev->repeat.delay_before = DEFAULT_DELAY_BEFORE_FIRST_REPEAT; 584 kbd_dev->repeat.delay_between = DEFAULT_REPEAT_DELAY; 585 586 587 // TODO: make more general 588 usb_hid_report_path_t *path = usb_hid_report_path(); 589 if (path == NULL) { 590 usb_log_error("Failed to create kbd report path.\n"); 591 usb_kbd_destroy(kbd_dev); 592 return ENOMEM; 593 } 594 595 int ret = 596 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 597 if (ret != EOK) { 598 usb_log_error("Failed to append item to kbd report path.\n"); 599 usb_hid_report_path_free(path); 600 usb_kbd_destroy(kbd_dev); 601 return ret; 602 } 603 604 usb_hid_report_path_set_report_id(path, 0); 605 606 kbd_dev->key_count = 607 usb_hid_report_size(&hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT); 608 609 usb_hid_report_path_free(path); 610 611 usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count); 612 613 kbd_dev->keys = calloc(kbd_dev->key_count, sizeof(int32_t)); 614 if (kbd_dev->keys == NULL) { 615 usb_log_error("Failed to allocate key buffer.\n"); 616 usb_kbd_destroy(kbd_dev); 617 return ENOMEM; 618 } 619 620 kbd_dev->keys_old = calloc(kbd_dev->key_count, sizeof(int32_t)); 621 if (kbd_dev->keys_old == NULL) { 622 usb_log_error("Failed to allocate old_key buffer.\n"); 623 usb_kbd_destroy(kbd_dev); 624 return ENOMEM; 625 } 626 627 /* Output report */ 628 kbd_dev->output_size = 0; 629 kbd_dev->output_buffer = usb_hid_report_output(&hid_dev->report, 630 &kbd_dev->output_size, 0); 631 if (kbd_dev->output_buffer == NULL) { 632 usb_log_error("Error creating output report buffer.\n"); 633 usb_kbd_destroy(kbd_dev); 634 return ENOMEM; 635 } 636 637 usb_log_debug("Output buffer size: %zu\n", kbd_dev->output_size); 638 639 kbd_dev->led_path = usb_hid_report_path(); 640 if (kbd_dev->led_path == NULL) { 641 usb_log_error("Failed to create kbd led report path.\n"); 642 usb_kbd_destroy(kbd_dev); 643 return ENOMEM; 644 } 645 646 ret = usb_hid_report_path_append_item( 647 kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0); 648 if (ret != EOK) { 649 usb_log_error("Failed to append to kbd/led report path.\n"); 650 usb_kbd_destroy(kbd_dev); 651 return ret; 652 } 653 654 kbd_dev->led_output_size = usb_hid_report_size( 655 &hid_dev->report, 0, USB_HID_REPORT_TYPE_OUTPUT); 656 657 usb_log_debug("Output report size (in items): %zu\n", 658 kbd_dev->led_output_size); 659 660 kbd_dev->led_data = calloc(kbd_dev->led_output_size, sizeof(int32_t)); 661 if (kbd_dev->led_data == NULL) { 662 usb_log_error("Error creating buffer for LED output report.\n"); 663 usb_kbd_destroy(kbd_dev); 664 return ENOMEM; 665 } 666 667 /* Set LEDs according to initial setup. 668 * Set Idle rate */ 669 usb_kbd_set_led(hid_dev, kbd_dev); 670 671 usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe, 672 hid_dev->usb_dev->interface_no, IDLE_RATE); 669 goto error; 670 } 671 672 fibril_add_ready(fid); 673 673 674 674 /* Save the KBD device structure into the HID device structure. */ 675 675 *data = kbd_dev; 676 676 677 kbd_dev->initialized = USB_KBD_STATUS_INITIALIZED;678 usb_log_debug("HID/KBD device structure initialized.\n");679 680 usb_log_debug("Creating KBD function...\n");681 ret = usb_kbd_create_function(kbd_dev);682 if (ret != EOK) {683 usb_kbd_destroy(kbd_dev);684 return ret;685 }686 687 /* Create new fibril for auto-repeat. */688 fid_t fid = fibril_create(usb_kbd_repeat_fibril, kbd_dev);689 if (fid == 0) {690 usb_log_error("Failed to start fibril for KBD auto-repeat");691 usb_kbd_destroy(kbd_dev);692 return ENOMEM;693 }694 fibril_add_ready(fid);695 696 677 return EOK; 678 error: 679 if (bound) 680 ddf_fun_unbind(fun); 681 if (fid != 0) 682 fibril_destroy(fid); 683 if (kbd_dev != NULL) { 684 free(kbd_dev->led_data); 685 if (kbd_dev->led_path != NULL) 686 usb_hid_report_path_free(kbd_dev->led_path); 687 if (kbd_dev->output_buffer != NULL) 688 usb_hid_report_output_free(kbd_dev->output_buffer); 689 free(kbd_dev->keys_old); 690 free(kbd_dev->keys); 691 } 692 if (path != NULL) 693 usb_hid_report_path_free(path); 694 if (fun != NULL) 695 ddf_fun_destroy(fun); 696 return rc; 697 697 } 698 698 … … 749 749 usb_hid_report_output_free(kbd_dev->output_buffer); 750 750 751 if (kbd_dev->fun) { 752 if (ddf_fun_unbind(kbd_dev->fun) != EOK) { 753 usb_log_warning("Failed to unbind %s.\n", 754 ddf_fun_get_name(kbd_dev->fun)); 755 } else { 756 usb_log_debug2("%s unbound.\n", 757 ddf_fun_get_name(kbd_dev->fun)); 758 ddf_fun_destroy(kbd_dev->fun); 759 } 760 } 751 ddf_fun_unbind(kbd_dev->fun); 752 ddf_fun_destroy(kbd_dev->fun); 761 753 } 762 754 -
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
r96e368a rcbfece7 34 34 * USB Mouse driver API. 35 35 */ 36 37 /* XXX Fix this */38 #define _DDF_DATA_IMPLANT39 36 40 37 #include <usb/debug.h> … … 249 246 } 250 247 251 #define FUN_UNBIND_DESTROY(fun) \252 if (fun) { \253 if (ddf_fun_unbind((fun)) == EOK) { \254 ddf_fun_destroy((fun)); \255 } else { \256 usb_log_error("Could not unbind function `%s', it " \257 "will not be destroyed.\n", ddf_fun_get_name(fun)); \258 } \259 } else (void)0260 261 static int usb_mouse_create_function(usb_hid_dev_t *hid_dev, usb_mouse_t *mouse)262 {263 assert(hid_dev != NULL);264 assert(mouse != NULL);265 266 /* Create the exposed function. */267 usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME);268 ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,269 HID_MOUSE_FUN_NAME);270 if (fun == NULL) {271 usb_log_error("Could not create DDF function node `%s'.\n",272 HID_MOUSE_FUN_NAME);273 return ENOMEM;274 }275 276 ddf_fun_set_ops(fun, &ops);277 ddf_fun_data_implant(fun, mouse);278 279 int rc = ddf_fun_bind(fun);280 if (rc != EOK) {281 usb_log_error("Could not bind DDF function `%s': %s.\n",282 ddf_fun_get_name(fun), str_error(rc));283 ddf_fun_destroy(fun);284 return rc;285 }286 287 usb_log_debug("Adding DDF function `%s' to category %s...\n",288 ddf_fun_get_name(fun), HID_MOUSE_CATEGORY);289 rc = ddf_fun_add_to_category(fun, HID_MOUSE_CATEGORY);290 if (rc != EOK) {291 usb_log_error(292 "Could not add DDF function to category %s: %s.\n",293 HID_MOUSE_CATEGORY, str_error(rc));294 FUN_UNBIND_DESTROY(fun);295 return rc;296 }297 mouse->mouse_fun = fun;298 return EOK;299 }300 301 248 /** Get highest index of a button mentioned in given report. 302 249 * … … 341 288 int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data) 342 289 { 290 ddf_fun_t *fun = NULL; 291 usb_mouse_t *mouse_dev = NULL; 292 bool bound = false; 293 int rc; 294 343 295 usb_log_debug("Initializing HID/Mouse structure...\n"); 344 296 … … 346 298 usb_log_error("Failed to init mouse structure: no structure" 347 299 " given.\n"); 348 return EINVAL; 349 } 350 351 usb_mouse_t *mouse_dev = calloc(1, sizeof(usb_mouse_t)); 300 rc = EINVAL; 301 goto error; 302 } 303 304 /* Create the exposed function. */ 305 usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME); 306 fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed, 307 HID_MOUSE_FUN_NAME); 308 if (fun == NULL) { 309 usb_log_error("Could not create DDF function node `%s'.\n", 310 HID_MOUSE_FUN_NAME); 311 rc = ENOMEM; 312 goto error; 313 } 314 315 ddf_fun_set_ops(fun, &ops); 316 317 mouse_dev = ddf_fun_data_alloc(fun, sizeof(usb_mouse_t)); 352 318 if (mouse_dev == NULL) { 353 319 usb_log_error("Error while creating USB/HID Mouse device " 354 320 "structure.\n"); 355 return ENOMEM; 321 rc = ENOMEM; 322 goto error; 356 323 } 357 324 … … 368 335 if (mouse_dev->buttons == NULL) { 369 336 usb_log_error(NAME ": out of memory, giving up on device!\n"); 370 free(mouse_dev);371 return ENOMEM;337 rc = ENOMEM; 338 goto error; 372 339 } 373 340 … … 376 343 hid_dev->usb_dev->interface_no, IDLE_RATE); 377 344 378 int rc = usb_mouse_create_function(hid_dev, mouse_dev);345 rc = ddf_fun_bind(fun); 379 346 if (rc != EOK) { 380 free(mouse_dev->buttons); 381 free(mouse_dev); 382 return rc; 383 } 347 usb_log_error("Could not bind DDF function `%s': %s.\n", 348 ddf_fun_get_name(fun), str_error(rc)); 349 goto error; 350 } 351 352 bound = true; 353 354 usb_log_debug("Adding DDF function `%s' to category %s...\n", 355 ddf_fun_get_name(fun), HID_MOUSE_CATEGORY); 356 rc = ddf_fun_add_to_category(fun, HID_MOUSE_CATEGORY); 357 if (rc != EOK) { 358 usb_log_error("Could not add DDF function to category %s: " 359 "%s.\n", HID_MOUSE_CATEGORY, str_error(rc)); 360 goto error; 361 } 362 363 mouse_dev->mouse_fun = fun; 384 364 385 365 /* Save the Mouse device structure into the HID device structure. */ 386 366 *data = mouse_dev; 387 388 367 return EOK; 368 error: 369 if (bound) 370 ddf_fun_unbind(fun); 371 if (mouse_dev != NULL) 372 free(mouse_dev->buttons); 373 if (fun != NULL) 374 ddf_fun_destroy(fun); 375 return rc; 389 376 } 390 377 … … 417 404 } 418 405 419 FUN_UNBIND_DESTROY(mouse_dev->mouse_fun); 420 406 ddf_fun_unbind(mouse_dev->mouse_fun); 421 407 free(mouse_dev->buttons); 408 ddf_fun_destroy(mouse_dev->mouse_fun); 422 409 } 423 410 -
uspace/drv/char/ns8250/ns8250.c
r96e368a rcbfece7 57 57 #include <ops/char_dev.h> 58 58 59 #include <ns.h> 60 #include <ipc/services.h> 61 #include <ipc/irc.h> 59 #include <irc.h> 62 60 #include <device/hw_res.h> 63 61 #include <ipc/serial_ctl.h> … … 488 486 static int ns8250_interrupt_enable(ns8250_t *ns) 489 487 { 490 /* 491 * Enable interrupt using IRC service. 492 * TODO: This is a temporary solution until the device framework 493 * takes care of this itself. 494 */ 495 async_sess_t *irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE, 496 SERVICE_IRC, 0, 0); 497 if (!irc_sess) { 488 /* Enable interrupt using IRC service. */ 489 int rc = irc_enable_interrupt(ns->irq); 490 if (rc != EOK) 498 491 return EIO; 499 } 500 501 async_exch_t *exch = async_exchange_begin(irc_sess); 502 if (!exch) { 503 return EIO; 504 } 505 async_msg_1(exch, IRC_ENABLE_INTERRUPT, ns->irq); 506 async_exchange_end(exch); 507 492 508 493 /* Read LSR to clear possible previous LSR interrupt */ 509 494 pio_read_8(&ns->regs->lsr); 510 495 511 496 /* Enable interrupt on the serial port. */ 512 497 ns8250_port_interrupts_enable(ns->regs); -
uspace/drv/nic/e1k/e1k.c
r96e368a rcbfece7 33 33 */ 34 34 35 /* XXX Fix this */36 #define _DDF_DATA_IMPLANT37 38 35 #include <assert.h> 39 36 #include <stdio.h> … … 42 39 #include <align.h> 43 40 #include <byteorder.h> 44 #include <sysinfo.h> 45 #include <ipc/irc.h> 46 #include <ipc/ns.h> 41 #include <irc.h> 42 #include <as.h> 47 43 #include <ddi.h> 48 #include <as.h>49 44 #include <ddf/log.h> 50 45 #include <ddf/interrupt.h> … … 1758 1753 e1000_enable_interrupts(e1000); 1759 1754 1760 nic_enable_interrupt(nic, e1000->irq); 1755 int rc = irc_enable_interrupt(e1000->irq); 1756 if (rc != EOK) { 1757 e1000_disable_interrupts(e1000); 1758 fibril_mutex_unlock(&e1000->ctrl_lock); 1759 fibril_mutex_unlock(&e1000->tx_lock); 1760 fibril_mutex_unlock(&e1000->rx_lock); 1761 return rc; 1762 } 1761 1763 1762 1764 e1000_clear_rx_ring(e1000); … … 1796 1798 e1000_disable_rx(e1000); 1797 1799 1798 nic_disable_interrupt(nic,e1000->irq);1800 irc_disable_interrupt(e1000->irq); 1799 1801 e1000_disable_interrupts(e1000); 1800 1802 … … 2148 2150 nic_set_ddf_fun(nic, fun); 2149 2151 ddf_fun_set_ops(fun, &e1000_dev_ops); 2150 ddf_fun_data_implant(fun, nic);2151 2152 2152 2153 rc = e1000_register_int_handler(nic); 2153 2154 if (rc != EOK) 2154 2155 goto err_fun_create; 2155 2156 rc = nic_connect_to_services(nic);2157 if (rc != EOK)2158 goto err_irq;2159 2156 2160 2157 rc = e1000_initialize_rx_structure(nic); … … 2379 2376 int main(void) 2380 2377 { 2381 int rc = nic_driver_init(NAME); 2382 if (rc != EOK) 2383 return rc; 2378 printf("%s: HelenOS E1000 network adapter driver\n", NAME); 2379 2380 if (nic_driver_init(NAME) != EOK) 2381 return 1; 2384 2382 2385 2383 nic_driver_implement(&e1000_driver_ops, &e1000_dev_ops, … … 2387 2385 2388 2386 ddf_log_init(NAME); 2389 ddf_msg(LVL_NOTE, "HelenOS E1000 driver started");2390 2387 return ddf_driver_main(&e1000_driver); 2391 2388 } -
uspace/drv/nic/ne2k/ne2k.c
r96e368a rcbfece7 38 38 */ 39 39 40 /* XXX Fix this */41 #define _DDF_DATA_IMPLANT42 43 40 #include <stdio.h> 44 41 #include <errno.h> 42 #include <irc.h> 45 43 #include <stdlib.h> 46 44 #include <str_error.h> … … 256 254 if (!ne2k->up) { 257 255 int rc = ne2k_up(ne2k); 256 if (rc != EOK) 257 return rc; 258 259 rc = irc_enable_interrupt(ne2k->irq); 258 260 if (rc != EOK) { 261 ne2k_down(ne2k); 259 262 return rc; 260 263 } 261 262 nic_enable_interrupt(nic_data, ne2k->irq);263 264 } 264 265 return EOK; … … 269 270 ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data); 270 271 271 nic_disable_interrupt(nic_data,ne2k->irq);272 (void) irc_disable_interrupt(ne2k->irq); 272 273 ne2k->receive_configuration = RCR_AB | RCR_AM; 273 274 ne2k_down(ne2k); … … 396 397 } 397 398 398 rc = nic_connect_to_services(nic_data);399 if (rc != EOK) {400 ne2k_dev_cleanup(dev);401 return rc;402 }403 404 399 fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0"); 405 400 if (fun == NULL) { … … 407 402 return ENOMEM; 408 403 } 404 409 405 nic_set_ddf_fun(nic_data, fun); 410 406 ddf_fun_set_ops(fun, &ne2k_dev_ops); 411 ddf_fun_data_implant(fun, nic_data);412 407 413 408 rc = ddf_fun_bind(fun); … … 443 438 int main(int argc, char *argv[]) 444 439 { 440 printf("%s: HelenOS NE 2000 network adapter driver\n", NAME); 441 445 442 nic_driver_init(NAME); 446 443 nic_driver_implement(&ne2k_driver_ops, &ne2k_dev_ops, &ne2k_nic_iface); -
uspace/drv/nic/rtl8139/driver.c
r96e368a rcbfece7 27 27 */ 28 28 29 /* XXX Fix this */30 #define _DDF_DATA_IMPLANT31 32 29 #include <assert.h> 33 30 #include <errno.h> … … 35 32 #include <byteorder.h> 36 33 #include <libarch/barrier.h> 37 38 34 #include <as.h> 39 35 #include <ddf/log.h> … … 42 38 #include <nic.h> 43 39 #include <pci_dev_iface.h> 44 45 #include <ipc/irc.h> 46 #include <sysinfo.h> 47 #include <ipc/ns.h> 48 40 #include <irc.h> 41 #include <stdio.h> 49 42 #include <str.h> 50 43 … … 960 953 rtl8139->int_mask = RTL_DEFAULT_INTERRUPTS; 961 954 rtl8139_hw_int_enable(rtl8139); 962 nic_enable_interrupt(nic_data, rtl8139->irq); 955 956 int rc = irc_enable_interrupt(rtl8139->irq); 957 if (rc != EOK) { 958 rtl8139_on_stopped(nic_data); 959 return rc; 960 } 963 961 964 962 ddf_msg(LVL_DEBUG, "Device activated, interrupt %d registered", rtl8139->irq); … … 1325 1323 goto err_pio; 1326 1324 1327 rc = nic_connect_to_services(nic_data);1328 if (rc != EOK) {1329 ddf_msg(LVL_ERROR, "Failed to connect to services (%d)", rc);1330 goto err_irq;1331 }1332 1333 1325 fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0"); 1334 1326 if (fun == NULL) { … … 1336 1328 goto err_srv; 1337 1329 } 1330 1338 1331 nic_set_ddf_fun(nic_data, fun); 1339 1332 ddf_fun_set_ops(fun, &rtl8139_dev_ops); 1340 ddf_fun_data_implant(fun, nic_data);1341 1333 1342 1334 rc = ddf_fun_bind(fun); … … 1361 1353 ddf_fun_destroy(fun); 1362 1354 err_srv: 1363 /* XXX Disconnect from services */1364 err_irq:1365 1355 unregister_interrupt_handler(dev, rtl8139->irq); 1366 1356 err_pio: … … 2180 2170 int main(void) 2181 2171 { 2172 printf("%s: HelenOS RTL8139 network adapter driver\n", NAME); 2173 2182 2174 int rc = nic_driver_init(NAME); 2183 2175 if (rc != EOK) 2184 2176 return rc; 2185 nic_driver_implement( 2186 &rtl8139_driver_ops, &rtl8139_dev_ops, &rtl8139_nic_iface); 2177 2178 nic_driver_implement(&rtl8139_driver_ops, &rtl8139_dev_ops, 2179 &rtl8139_nic_iface); 2187 2180 2188 2181 ddf_log_init(NAME); 2189 ddf_msg(LVL_NOTE, "HelenOS RTL8139 driver started");2190 2182 return ddf_driver_main(&rtl8139_driver); 2191 2183 } -
uspace/drv/nic/rtl8169/defs.h
r96e368a rcbfece7 39 39 #include <sys/types.h> 40 40 #include <ddi.h> 41 42 #define PCI_VID_REALTEK 0x10ec 43 #define PCI_VID_DLINK 0x1186 41 44 42 45 /** Size of RTL8169 registers address space */ -
uspace/drv/nic/rtl8169/driver.c
r96e368a rcbfece7 33 33 #include <align.h> 34 34 #include <byteorder.h> 35 #include <irc.h> 35 36 #include <libarch/barrier.h> 36 37 … … 388 389 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 389 390 391 /* Get PCI VID & PID */ 392 rc = pci_config_space_read_16(ddf_dev_parent_sess_get(dev), 393 PCI_VENDOR_ID, &rtl8169->pci_vid); 394 if (rc != EOK) 395 return rc; 396 397 rc = pci_config_space_read_16(ddf_dev_parent_sess_get(dev), 398 PCI_DEVICE_ID, &rtl8169->pci_pid); 399 if (rc != EOK) 400 return rc; 401 390 402 /* Map register space */ 391 403 rc = pio_enable(rtl8169->regs_phys, RTL8169_IO_SIZE, &rtl8169->regs); … … 418 430 uint8_t cr_value = pio_read_8(rtl8169->regs + CR); 419 431 pio_write_8(rtl8169->regs + CR, cr_value | CR_TE | CR_RE); 420 421 rc = nic_connect_to_services(nic_data);422 if (rc != EOK) {423 ddf_msg(LVL_ERROR, "Failed to connect to services (%d)", rc);424 goto err_irq;425 }426 432 427 433 fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0"); … … 473 479 int rc; 474 480 475 rtl8169_set_hwaddr(rtl8169, addr); 481 fibril_mutex_lock(&rtl8169->rx_lock); 482 fibril_mutex_lock(&rtl8169->tx_lock); 476 483 477 484 rc = nic_report_address(nic_data, addr); … … 479 486 return rc; 480 487 488 rtl8169_set_hwaddr(rtl8169, addr); 489 490 fibril_mutex_unlock(&rtl8169->rx_lock); 491 fibril_mutex_unlock(&rtl8169->tx_lock); 492 481 493 return EOK; 482 494 } … … 484 496 static int rtl8169_get_device_info(ddf_fun_t *fun, nic_device_info_t *info) 485 497 { 486 487 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "Realtek"); 488 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8169"); 498 nic_t *nic_data = nic_get_from_ddf_fun(fun); 499 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 500 501 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "Unknown"); 502 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "Unknown"); 503 504 if (rtl8169->pci_vid == PCI_VID_REALTEK) 505 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "Realtek"); 506 507 if (rtl8169->pci_vid == PCI_VID_DLINK) 508 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "D-Link"); 509 510 if (rtl8169->pci_pid == 0x8168) 511 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8168"); 512 513 if (rtl8169->pci_pid == 0x8169) 514 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8169"); 515 516 if (rtl8169->pci_pid == 0x8110) 517 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8110"); 489 518 490 519 return EOK; … … 541 570 bmcr &= ~(BMCR_DUPLEX | BMCR_SPD_100 | BMCR_SPD_1000); 542 571 572 /* Disable autonegotiation */ 573 bmcr &= ~BMCR_AN_ENABLE; 574 543 575 if (duplex == NIC_CM_FULL_DUPLEX) 544 576 bmcr |= BMCR_DUPLEX; … … 609 641 static int rtl8169_autoneg_restart(ddf_fun_t *fun) 610 642 { 643 rtl8169_t *rtl8169 = nic_get_specific(nic_get_from_ddf_fun(fun)); 644 uint16_t bmcr = rtl8169_mii_read(rtl8169, MII_BMCR); 645 646 bmcr |= BMCR_AN_ENABLE; 647 rtl8169_mii_write(rtl8169, MII_BMCR, bmcr); 611 648 return EOK; 612 649 } … … 706 743 707 744 pio_write_16(rtl8169->regs + IMR, 0xffff); 708 nic_enable_interrupt(nic_data,rtl8169->irq);745 irc_enable_interrupt(rtl8169->irq); 709 746 710 747 return EOK; … … 888 925 } 889 926 927 /* Receive underrun */ 928 if (isr & INT_RXOVW) { 929 /* just ack.. */ 930 pio_write_16(rtl8169->regs + ISR, INT_RXOVW); 931 } 932 890 933 if (isr & INT_SERR) { 891 934 ddf_msg(LVL_ERROR, "System error interrupt"); -
uspace/drv/nic/rtl8169/driver.h
r96e368a rcbfece7 55 55 /** The irq assigned */ 56 56 int irq; 57 /** PCI Vendor and Product ids */ 58 uint16_t pci_vid; 59 uint16_t pci_pid; 57 60 /** Mask of the turned interupts (IMR value) */ 58 61 uint16_t int_mask; -
uspace/lib/c/Makefile
r96e368a rcbfece7 109 109 generic/iplink.c \ 110 110 generic/iplink_srv.c \ 111 generic/irc.c \ 111 112 generic/ieee_double.c \ 112 113 generic/power_of_ten.c \ -
uspace/lib/c/include/ipc/irc.h
r96e368a rcbfece7 33 33 */ 34 34 35 #ifndef LIBC_I RC_H_36 #define LIBC_I RC_H_35 #ifndef LIBC_IPC_IRC_H_ 36 #define LIBC_IPC_IRC_H_ 37 37 38 38 #include <ipc/common.h> -
uspace/lib/drv/include/pci_dev_iface.h
r96e368a rcbfece7 40 40 #include "ddf/driver.h" 41 41 42 #define PCI_VENDOR_ID 0x00 42 43 #define PCI_DEVICE_ID 0x02 43 44 -
uspace/lib/nic/include/nic.h
r96e368a rcbfece7 216 216 217 217 /* Functions called in add_device */ 218 extern int nic_connect_to_services(nic_t *);219 218 extern int nic_get_resources(nic_t *, hw_res_list_parsed_t *); 220 219 extern void nic_set_specific(nic_t *, void *); … … 245 244 extern void nic_received_frame(nic_t *, nic_frame_t *); 246 245 extern void nic_received_frame_list(nic_t *, nic_frame_list_t *); 247 extern void nic_disable_interrupt(nic_t *, int);248 extern void nic_enable_interrupt(nic_t *, int);249 246 extern nic_poll_mode_t nic_query_poll_mode(nic_t *, struct timeval *); 250 247 -
uspace/lib/nic/include/nic_driver.h
r96e368a rcbfece7 80 80 /** Client callback session */ 81 81 async_sess_t *client_session; 82 /** Phone to APIC or i8259 */83 async_sess_t *irc_session;84 82 /** Current polling mode of the NIC */ 85 83 nic_poll_mode_t poll_mode; -
uspace/lib/nic/src/nic_driver.c
r96e368a rcbfece7 42 42 #include <stdio.h> 43 43 #include <str_error.h> 44 #include <ipc/services.h>45 #include <ipc/ns.h>46 #include <ipc/irc.h>47 44 #include <sysinfo.h> 48 45 #include <as.h> … … 378 375 } 379 376 380 381 /**382 * Enable interrupts for this driver.383 *384 * @param nic_data385 * @param irq The IRQ number for this device386 */387 void nic_enable_interrupt(nic_t *nic_data, int irq)388 {389 async_exch_t *exch = async_exchange_begin(nic_data->irc_session);390 async_msg_1(exch, IRC_ENABLE_INTERRUPT, irq);391 async_exchange_end(exch);392 }393 394 /**395 * Disable interrupts for this driver.396 *397 * @param nic_data398 * @param irq The IRQ number for this device399 */400 void nic_disable_interrupt(nic_t *nic_data, int irq)401 {402 async_exch_t *exch = async_exchange_begin(nic_data->irc_session);403 async_msg_1(exch, IRC_CLEAR_INTERRUPT, irq);404 async_exchange_end(exch);405 }406 407 377 /** Get the polling mode information from the device 408 378 * … … 420 390 return nic_data->poll_mode; 421 391 }; 422 423 /**424 * Connect to IRC service. This function should be called only from425 * the add_device handler, thus no locking is required.426 *427 * @param nic_data428 *429 * @return EOK If connection was successful.430 * @return EINVAL If the IRC service cannot be determined.431 * @return EREFUSED If IRC service cannot be connected.432 */433 int nic_connect_to_services(nic_t *nic_data)434 {435 /* IRC service */436 sysarg_t apic;437 sysarg_t i8259;438 services_t irc_service = -1;439 if (((sysinfo_get_value("apic", &apic) == EOK) && (apic)) ||440 ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259)))441 irc_service = SERVICE_IRC;442 else443 return EINVAL;444 445 nic_data->irc_session = service_connect_blocking(EXCHANGE_SERIALIZE,446 irc_service, 0, 0);447 if (nic_data->irc_session == NULL)448 return errno;449 450 return EOK;451 }452 392 453 393 /** Inform the NICF about poll mode … … 668 608 nic_data->state = NIC_STATE_STOPPED; 669 609 nic_data->client_session = NULL; 670 nic_data->irc_session = NULL;671 610 nic_data->poll_mode = NIC_POLL_IMMEDIATE; 672 611 nic_data->default_poll_mode = NIC_POLL_IMMEDIATE; … … 975 914 nic_t *nic_get_from_ddf_fun(ddf_fun_t *fun) 976 915 { 977 return (nic_t *) ddf_ fun_data_get(fun);916 return (nic_t *) ddf_dev_data_get(ddf_fun_get_dev(fun)); 978 917 } 979 918 -
uspace/srv/net/ethip/arp.c
r96e368a rcbfece7 119 119 return rc; 120 120 121 (void) atrans_wait_timeout(ARP_REQUEST_TIMEOUT); 122 123 return atrans_lookup(ip_addr, mac_addr); 121 return atrans_lookup_timeout(ip_addr, ARP_REQUEST_TIMEOUT, mac_addr); 124 122 } 125 123 -
uspace/srv/net/ethip/atrans.c
r96e368a rcbfece7 103 103 } 104 104 105 int atrans_lookup(addr32_t ip_addr, addr48_t mac_addr)105 static int atrans_lookup_locked(addr32_t ip_addr, addr48_t mac_addr) 106 106 { 107 fibril_mutex_lock(&atrans_list_lock);108 107 ethip_atrans_t *atrans = atrans_find(ip_addr); 109 if (atrans == NULL) { 110 fibril_mutex_unlock(&atrans_list_lock); 108 if (atrans == NULL) 111 109 return ENOENT; 112 } 113 114 fibril_mutex_unlock(&atrans_list_lock); 110 115 111 addr48(atrans->mac_addr, mac_addr); 116 112 return EOK; 117 113 } 118 114 119 int atrans_ wait_timeout(suseconds_t timeout)115 int atrans_lookup(addr32_t ip_addr, addr48_t mac_addr) 120 116 { 117 int rc; 118 121 119 fibril_mutex_lock(&atrans_list_lock); 122 int rc = fibril_condvar_wait_timeout(&atrans_cv, &atrans_list_lock, 123 timeout); 120 rc = atrans_lookup_locked(ip_addr, mac_addr); 124 121 fibril_mutex_unlock(&atrans_list_lock); 125 122 123 return rc; 124 } 125 126 static void atrans_lookup_timeout_handler(void *arg) 127 { 128 bool *timedout = (bool *)arg; 129 130 fibril_mutex_lock(&atrans_list_lock); 131 *timedout = true; 132 fibril_mutex_unlock(&atrans_list_lock); 133 fibril_condvar_broadcast(&atrans_cv); 134 } 135 136 int atrans_lookup_timeout(addr32_t ip_addr, suseconds_t timeout, 137 addr48_t mac_addr) 138 { 139 fibril_timer_t *t; 140 bool timedout; 141 int rc; 142 143 t = fibril_timer_create(NULL); 144 if (t == NULL) 145 return ENOMEM; 146 147 timedout = false; 148 fibril_timer_set(t, timeout, atrans_lookup_timeout_handler, &timedout); 149 150 fibril_mutex_lock(&atrans_list_lock); 151 152 while ((rc = atrans_lookup_locked(ip_addr, mac_addr)) == ENOENT && 153 !timedout) { 154 fibril_condvar_wait(&atrans_cv, &atrans_list_lock); 155 } 156 157 fibril_mutex_unlock(&atrans_list_lock); 158 (void) fibril_timer_clear(t); 159 fibril_timer_destroy(t); 160 126 161 return rc; 127 162 } -
uspace/srv/net/ethip/atrans.h
r96e368a rcbfece7 45 45 extern int atrans_remove(addr32_t); 46 46 extern int atrans_lookup(addr32_t, addr48_t); 47 extern int atrans_ wait_timeout(suseconds_t);47 extern int atrans_lookup_timeout(addr32_t, suseconds_t, addr48_t); 48 48 49 49 #endif -
uspace/srv/net/inetsrv/inet_link.c
r96e368a rcbfece7 465 465 list_foreach(inet_links, link_list, inet_link_t, ilink) { 466 466 id_list[i++] = ilink->svc_id; 467 log_msg(LOG_DEFAULT, LVL_NOTE, "add link to list");468 467 } 469 468 470 469 fibril_mutex_unlock(&inet_links_lock); 471 470 472 log_msg(LOG_DEFAULT, LVL_NOTE, "return %zu links", count);473 471 *rid_list = id_list; 474 472 *rcount = count; -
uspace/srv/net/inetsrv/pdu.c
r96e368a rcbfece7 106 106 { 107 107 /* Upper bound for fragment offset field */ 108 size_t fragoff_limit = 1 << (FF_FRAGOFF_h - FF_FRAGOFF_l );108 size_t fragoff_limit = 1 << (FF_FRAGOFF_h - FF_FRAGOFF_l + 1); 109 109 110 110 /* Verify that total size of datagram is within reasonable bounds */ 111 if ( offs +packet->size > FRAG_OFFS_UNIT * fragoff_limit)111 if (packet->size > FRAG_OFFS_UNIT * fragoff_limit) 112 112 return ELIMIT; 113 113 -
uspace/srv/net/inetsrv/reass.c
r96e368a rcbfece7 196 196 return ENOMEM; 197 197 198 memcpy(data_copy, packet->data, packet->size); 199 198 200 frag->packet = *packet; 199 201 frag->packet.data = data_copy; … … 216 218 break; 217 219 218 link = li nk->next;220 link = list_next(link, &rdg->frags); 219 221 } 220 222 … … 240 242 assert(!list_empty(&rdg->frags)); 241 243 244 link = list_first(&rdg->frags); 245 assert(link != NULL); 246 247 frag = list_get_instance(link, reass_frag_t, 248 dgram_link); 249 242 250 /* First fragment must be at offset zero */ 243 frag = list_get_instance(list_first(&rdg->frags), reass_frag_t,244 dgram_link);245 251 if (frag->packet.offs != 0) 246 252 return false; 247 253 248 254 prev = frag; 255 249 256 while (true) { 250 link = frag->dgram_link.next;257 link = list_next(link, &rdg->frags); 251 258 if (link == NULL) 252 return false;259 break; 253 260 254 261 /* Each next fragment must follow immediately or overlap */ … … 288 295 uint8_t proto; 289 296 reass_frag_t *frag; 297 int rc; 290 298 291 299 /* … … 307 315 308 316 /* Upper bound for fragment offset field */ 309 fragoff_limit = 1 << (FF_FRAGOFF_h - FF_FRAGOFF_l );317 fragoff_limit = 1 << (FF_FRAGOFF_h - FF_FRAGOFF_l + 1); 310 318 311 319 /* Verify that total size of datagram is within reasonable bounds */ … … 343 351 } 344 352 345 return inet_recv_dgram_local(&dgram, proto); 353 rc = inet_recv_dgram_local(&dgram, proto); 354 free(dgram.data); 355 return rc; 346 356 } 347 357 -
uspace/srv/net/tcp/tqueue.c
r96e368a rcbfece7 59 59 static void tcp_tqueue_timer_clear(tcp_conn_t *conn); 60 60 61 #include <stdio.h>62 61 int tcp_tqueue_init(tcp_tqueue_t *tqueue, tcp_conn_t *conn) 63 62 { 64 printf("tcp_tqueue_init\n");65 63 tqueue->conn = conn; 66 64 tqueue->timer = fibril_timer_create(&conn->lock); … … 80 78 void tcp_tqueue_fini(tcp_tqueue_t *tqueue) 81 79 { 82 printf("tcp_tqueue_fini\n");83 80 if (tqueue->timer != NULL) { 84 81 fibril_timer_destroy(tqueue->timer); -
uspace/srv/net/udp/assoc.c
r96e368a rcbfece7 275 275 276 276 rc = udp_transmit_pdu(pdu); 277 udp_pdu_delete(pdu); 278 277 279 if (rc != EOK) 278 280 return EIO; 279 280 udp_pdu_delete(pdu);281 281 282 282 return EOK; … … 335 335 /* XXX Generate ICMP error. */ 336 336 /* XXX Might propagate error directly by error return. */ 337 udp_msg_delete(msg); 337 338 return; 338 339 } -
uspace/srv/net/udp/udp_type.h
r96e368a rcbfece7 43 43 #include <inet/addr.h> 44 44 45 #define UDP_FRAGMENT_SIZE 4096 46 45 #define UDP_FRAGMENT_SIZE 65535 47 46 48 47 typedef enum {
Note:
See TracChangeset
for help on using the changeset viewer.