Changeset d51838f in mainline for uspace/drv/nic
- Timestamp:
- 2017-10-14T22:49:18Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 75911d24
- Parents:
- ce732e74
- Location:
- uspace/drv/nic
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/e1k/e1k.c
rce732e74 rd51838f 40 40 #include <thread.h> 41 41 #include <byteorder.h> 42 #include <irc.h>43 42 #include <as.h> 44 43 #include <ddi.h> 45 44 #include <ddf/log.h> 46 45 #include <ddf/interrupt.h> 46 #include <device/hw_res.h> 47 47 #include <device/hw_res_parsed.h> 48 48 #include <pci_dev_iface.h> … … 116 116 /** E1000 device data */ 117 117 typedef struct { 118 /** DDF device */ 119 ddf_dev_t *dev; 120 /** Parent session */ 121 async_sess_t *parent_sess; 118 122 /** Device configuration */ 119 123 e1000_info_t info; … … 1757 1761 e1000_enable_interrupts(e1000); 1758 1762 1759 int rc = irc_enable_interrupt(e1000->irq);1763 int rc = hw_res_enable_interrupt(e1000->parent_sess, e1000->irq); 1760 1764 if (rc != EOK) { 1761 1765 e1000_disable_interrupts(e1000); … … 1802 1806 e1000_disable_rx(e1000); 1803 1807 1804 irc_disable_interrupt(e1000->irq);1808 hw_res_disable_interrupt(e1000->parent_sess, e1000->irq); 1805 1809 e1000_disable_interrupts(e1000); 1806 1810 … … 1884 1888 1885 1889 memset(e1000, 0, sizeof(e1000_t)); 1890 e1000->dev = dev; 1886 1891 1887 1892 nic_set_specific(nic, e1000); … … 1998 2003 ddf_msg(LVL_ERROR, "Unable to allocate device softstate"); 1999 2004 return ENOMEM; 2005 } 2006 2007 e1000->parent_sess = ddf_dev_parent_sess_get(dev); 2008 if (e1000->parent_sess == NULL) { 2009 ddf_msg(LVL_ERROR, "Failed connecting parent device."); 2010 return EIO; 2000 2011 } 2001 2012 … … 2119 2130 { 2120 2131 ddf_fun_t *fun; 2121 assert(dev);2122 2132 2123 2133 /* Initialize device structure for E1000 */ -
uspace/drv/nic/ne2k/dp8390.h
rce732e74 rd51838f 50 50 #define __NET_NETIF_DP8390_H__ 51 51 52 #include <async.h> 53 #include <ddf/driver.h> 52 54 #include <fibril_synch.h> 53 55 #include <nic.h> … … 223 225 224 226 typedef struct { 227 /** DDF device */ 228 ddf_dev_t *dev; 229 /** Parent session */ 230 async_sess_t *parent_sess; 225 231 /* Device configuration */ 226 232 void *base_port; /**< Port assigned from ISA configuration **/ -
uspace/drv/nic/ne2k/ne2k.c
rce732e74 rd51838f 40 40 #include <stdio.h> 41 41 #include <errno.h> 42 #include < irc.h>42 #include <device/hw_res.h> 43 43 #include <stdlib.h> 44 44 #include <str_error.h> … … 256 256 return rc; 257 257 258 rc = irc_enable_interrupt(ne2k->irq);258 rc = hw_res_enable_interrupt(ne2k->parent_sess, ne2k->irq); 259 259 if (rc != EOK) { 260 260 ne2k_down(ne2k); … … 269 269 ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data); 270 270 271 (void) irc_disable_interrupt(ne2k->irq);271 (void) hw_res_disable_interrupt(ne2k->parent_sess, ne2k->irq); 272 272 ne2k->receive_configuration = RCR_AB | RCR_AM; 273 273 ne2k_down(ne2k); … … 384 384 } 385 385 386 ne2k->dev = dev; 387 ne2k->parent_sess = ddf_dev_parent_sess_get(dev); 388 if (ne2k->parent_sess == NULL) { 389 ne2k_dev_cleanup(dev); 390 return ENOMEM; 391 } 392 386 393 int rc = ne2k_dev_init(nic_data); 387 394 if (rc != EOK) { -
uspace/drv/nic/rtl8139/driver.c
rce732e74 rd51838f 36 36 #include <ddf/log.h> 37 37 #include <ddf/interrupt.h> 38 #include <device/hw_res.h> 38 39 #include <io/log.h> 39 40 #include <nic.h> 40 41 #include <pci_dev_iface.h> 41 #include <irc.h>42 42 #include <stdio.h> 43 43 #include <str.h> … … 920 920 rtl8139_hw_int_set(rtl8139); 921 921 922 int rc = irc_enable_interrupt(rtl8139->irq);922 int rc = hw_res_enable_interrupt(rtl8139->parent_sess, rtl8139->irq); 923 923 if (rc != EOK) { 924 924 rtl8139_on_stopped(nic_data); … … 976 976 return NULL; 977 977 978 rtl8139_t *rtl8139 = malloc(sizeof(rtl8139_t));978 rtl8139_t *rtl8139 = calloc(1, sizeof(rtl8139_t)); 979 979 if (!rtl8139) { 980 980 nic_unbind_and_destroy(dev); … … 982 982 } 983 983 984 memset(rtl8139, 0, sizeof(rtl8139_t));984 rtl8139->dev = dev; 985 985 986 986 rtl8139->nic_data = nic_data; … … 1166 1166 1167 1167 ddf_msg(LVL_DEBUG, "rtl8139: dev_data created"); 1168 rtl8139->parent_sess = ddf_dev_parent_sess_get(dev); 1169 if (rtl8139->parent_sess == NULL) { 1170 ddf_msg(LVL_ERROR, "Error connecting parent device."); 1171 return EIO; 1172 } 1168 1173 1169 1174 /* Obtain and fill hardware resources info and connect to parent */ … … 1258 1263 ddf_fun_t *fun; 1259 1264 1260 assert(dev);1261 1265 ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %zu)", 1262 1266 ddf_dev_get_name(dev), ddf_dev_get_handle(dev)); -
uspace/drv/nic/rtl8139/driver.h
rce732e74 rd51838f 87 87 /** RTL8139 device data */ 88 88 typedef struct rtl8139_data { 89 /** DDF device */ 90 ddf_dev_t *dev; 91 /** Parent session */ 92 async_sess_t *parent_sess; 89 93 /** I/O address of the device */ 90 94 void *io_addr; -
uspace/drv/nic/rtl8169/driver.c
rce732e74 rd51838f 31 31 #include <align.h> 32 32 #include <byteorder.h> 33 #include <irc.h>34 33 #include <libarch/barrier.h> 35 34 … … 38 37 #include <ddf/log.h> 39 38 #include <ddf/interrupt.h> 39 #include <device/hw_res.h> 40 #include <device/hw_res_parsed.h> 40 41 #include <io/log.h> 41 42 #include <nic.h> 42 43 #include <pci_dev_iface.h> 43 44 44 #include <ipc/irc.h>45 45 #include <sysinfo.h> 46 46 #include <ipc/ns.h> … … 396 396 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 397 397 398 rtl8169->dev = dev; 399 rtl8169->parent_sess = ddf_dev_parent_sess_get(dev); 400 if (rtl8169->parent_sess == NULL) 401 return EIO; 402 398 403 /* Get PCI VID & PID */ 399 rc = pci_config_space_read_16( ddf_dev_parent_sess_get(dev),400 PCI_VENDOR_ID,&rtl8169->pci_vid);404 rc = pci_config_space_read_16(rtl8169->parent_sess, PCI_VENDOR_ID, 405 &rtl8169->pci_vid); 401 406 if (rc != EOK) 402 407 return rc; 403 408 404 rc = pci_config_space_read_16( ddf_dev_parent_sess_get(dev),405 PCI_DEVICE_ID,&rtl8169->pci_pid);409 rc = pci_config_space_read_16(rtl8169->parent_sess, PCI_DEVICE_ID, 410 &rtl8169->pci_pid); 406 411 if (rc != EOK) 407 412 return rc; … … 745 750 746 751 pio_write_16(rtl8169->regs + IMR, 0xffff); 747 irc_enable_interrupt(rtl8169->irq); 752 /* XXX Check return value */ 753 hw_res_enable_interrupt(rtl8169->parent_sess, rtl8169->irq); 748 754 749 755 return EOK; -
uspace/drv/nic/rtl8169/driver.h
rce732e74 rd51838f 49 49 /** RTL8139 device data */ 50 50 typedef struct rtl8169_data { 51 /** DDF device */ 52 ddf_dev_t *dev; 53 /** Parent session */ 54 async_sess_t *parent_sess; 51 55 /** I/O address of the device */ 52 56 void *regs_phys;
Note:
See TracChangeset
for help on using the changeset viewer.