Changes in uspace/drv/nic/rtl8139/driver.c [8820544:d87561c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/rtl8139/driver.c
r8820544 rd87561c 27 27 */ 28 28 29 /* XXX Fix this */ 30 #define _DDF_DATA_IMPLANT 31 29 32 #include <assert.h> 30 33 #include <errno.h> … … 32 35 #include <byteorder.h> 33 36 #include <libarch/barrier.h> 37 34 38 #include <as.h> 35 39 #include <ddf/log.h> … … 37 41 #include <io/log.h> 38 42 #include <nic.h> 39 #include <pci_dev_iface.h> 40 #include <irc.h> 41 #include <stdio.h> 43 #include <device/pci.h> 44 45 #include <ipc/irc.h> 46 #include <sysinfo.h> 47 #include <ipc/ns.h> 48 42 49 #include <str.h> 43 50 … … 183 190 return; 184 191 } 192 193 #include <device/pci.h> 185 194 186 195 /** Set PmEn (Power management enable) bit value … … 852 861 /** Handle device interrupt 853 862 * 854 * @param iid The IPC call id 855 * @param icall The IPC call structure 856 * @param dev The rtl8139 device 857 * 858 */ 859 static void rtl8139_interrupt_handler(ipc_callid_t iid, ipc_call_t *icall, 860 ddf_dev_t *dev) 863 * @param dev The rtl8139 device 864 * @param iid The IPC call id 865 * @param icall The IPC call structure 866 */ 867 static void rtl8139_interrupt_handler(ddf_dev_t *dev, ipc_callid_t iid, 868 ipc_call_t *icall) 861 869 { 862 870 assert(dev); … … 954 962 rtl8139->int_mask = RTL_DEFAULT_INTERRUPTS; 955 963 rtl8139_hw_int_enable(rtl8139); 956 957 int rc = irc_enable_interrupt(rtl8139->irq); 958 if (rc != EOK) { 959 rtl8139_on_stopped(nic_data); 960 return rc; 961 } 964 nic_enable_interrupt(nic_data, rtl8139->irq); 962 965 963 966 ddf_msg(LVL_DEBUG, "Device activated, interrupt %d registered", rtl8139->irq); … … 1084 1087 ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", ddf_dev_get_name(dev), rtl8139->irq); 1085 1088 1086 rtl8139->io_addr = IOADDR_TO_PTR( RNGABS(hw_resources->io_ranges.ranges[0]));1089 rtl8139->io_addr = IOADDR_TO_PTR(hw_resources->io_ranges.ranges[0].address); 1087 1090 if (hw_resources->io_ranges.ranges[0].size < RTL8139_IO_SIZE) { 1088 1091 ddf_msg(LVL_ERROR, "i/o range assigned to the device " … … 1140 1143 1141 1144 ddf_msg(LVL_DEBUG, "Creating buffers"); 1142 1143 rtl8139->tx_buff_virt = AS_AREA_ANY; 1144 rc = dmamem_map_anonymous(TX_PAGES * PAGE_SIZE, DMAMEM_4GiB, 1145 AS_AREA_WRITE, 0, &rtl8139->tx_buff_phys, &rtl8139->tx_buff_virt); 1145 1146 rc = dmamem_map_anonymous(TX_PAGES * PAGE_SIZE, AS_AREA_WRITE, 0, 1147 &rtl8139->tx_buff_phys, &rtl8139->tx_buff_virt); 1146 1148 if (rc != EOK) { 1147 1149 ddf_msg(LVL_ERROR, "Can not allocate transmitter buffers."); … … 1161 1163 ddf_msg(LVL_DEBUG, "Allocating receiver buffer of the size %d bytes", 1162 1164 RxBUF_TOT_LENGTH); 1163 1164 rtl8139->rx_buff_virt = AS_AREA_ANY; 1165 rc = dmamem_map_anonymous(RxBUF_TOT_LENGTH, DMAMEM_4GiB, 1166 AS_AREA_READ, 0, &rtl8139->rx_buff_phys, &rtl8139->rx_buff_virt); 1165 1166 rc = dmamem_map_anonymous(RxBUF_TOT_LENGTH, AS_AREA_READ, 0, 1167 &rtl8139->rx_buff_phys, &rtl8139->rx_buff_virt); 1167 1168 if (rc != EOK) { 1168 1169 ddf_msg(LVL_ERROR, "Can not allocate receive buffer."); … … 1324 1325 goto err_pio; 1325 1326 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 1326 1333 fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0"); 1327 1334 if (fun == NULL) { … … 1329 1336 goto err_srv; 1330 1337 } 1331 1332 1338 nic_set_ddf_fun(nic_data, fun); 1333 1339 ddf_fun_set_ops(fun, &rtl8139_dev_ops); 1340 ddf_fun_data_implant(fun, nic_data); 1334 1341 1335 1342 rc = ddf_fun_bind(fun); … … 1354 1361 ddf_fun_destroy(fun); 1355 1362 err_srv: 1363 /* XXX Disconnect from services */ 1364 err_irq: 1356 1365 unregister_interrupt_handler(dev, rtl8139->irq); 1357 1366 err_pio: … … 2171 2180 int main(void) 2172 2181 { 2173 printf("%s: HelenOS RTL8139 network adapter driver\n", NAME);2174 2175 2182 int rc = nic_driver_init(NAME); 2176 2183 if (rc != EOK) 2177 2184 return rc; 2178 2179 nic_driver_implement(&rtl8139_driver_ops, &rtl8139_dev_ops, 2180 &rtl8139_nic_iface); 2185 nic_driver_implement( 2186 &rtl8139_driver_ops, &rtl8139_dev_ops, &rtl8139_nic_iface); 2181 2187 2182 2188 ddf_log_init(NAME); 2189 ddf_msg(LVL_NOTE, "HelenOS RTL8139 driver started"); 2183 2190 return ddf_driver_main(&rtl8139_driver); 2184 2191 }
Note:
See TracChangeset
for help on using the changeset viewer.