Changes in uspace/drv/nic/rtl8139/driver.c [9d58539:1ae74c6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/rtl8139/driver.c
r9d58539 r1ae74c6 27 27 */ 28 28 29 /* XXX Fix this */ 30 #define _DDF_DATA_IMPLANT 31 29 32 #include <assert.h> 30 33 #include <errno.h> 31 34 #include <align.h> 32 35 #include <byteorder.h> 33 #include <libarch/ddi.h>34 36 #include <libarch/barrier.h> 35 37 … … 44 46 #include <sysinfo.h> 45 47 #include <ipc/ns.h> 46 47 #include <net_checksum.h>48 48 49 49 #include <str.h> … … 214 214 rtl8139_regs_lock(rtl8139->io_port); 215 215 216 async_sess_t *pci_sess = 217 ddf_dev_parent_sess_get(nic_get_ddf_dev(rtl8139->nic_data)); 218 216 219 if (bit_val) { 217 async_sess_t *pci_sess =218 nic_get_ddf_dev(rtl8139->nic_data)->parent_sess;219 220 uint8_t pmen; 220 221 pci_config_space_read_8(pci_sess, 0x55, &pmen); 221 222 pci_config_space_write_8(pci_sess, 0x55, pmen | 1 | (1 << 7)); 222 223 } else { 223 async_sess_t *pci_sess =224 nic_get_ddf_dev(rtl8139->nic_data)->parent_sess;225 224 uint8_t pmen; 226 225 pci_config_space_read_8(pci_sess, 0x55, &pmen); … … 620 619 /* Check if the header is valid, otherwise we are lost in the buffer */ 621 620 if (size == 0 || size > RTL8139_FRAME_MAX_LENGTH) { 622 ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (size: %4" PRIu16", "623 "header 0x%4" PRIx16". Offset: %zu)", size, frame_header,621 ddf_msg(LVL_ERROR, "Receiver error -> receiver reset (size: %4" PRIu16 ", " 622 "header 0x%4" PRIx16 ". Offset: %d)", size, frame_header, 624 623 rx_offset); 625 624 goto rx_err; … … 1054 1053 assert(dev); 1055 1054 1056 if (d ev->driver_data)1055 if (ddf_dev_data_get(dev)) 1057 1056 nic_unbind_and_destroy(dev); 1058 1059 if (dev->parent_sess != NULL) {1060 async_hangup(dev->parent_sess);1061 dev->parent_sess = NULL;1062 }1063 1057 } 1064 1058 … … 1082 1076 1083 1077 if (hw_resources->irqs.count != 1) { 1084 ddf_msg(LVL_ERROR, "%s device: unexpected irq count", d ev->name);1078 ddf_msg(LVL_ERROR, "%s device: unexpected irq count", ddf_dev_get_name(dev)); 1085 1079 return EINVAL; 1086 1080 }; 1087 1081 if (hw_resources->io_ranges.count != 1) { 1088 ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", d ev->name);1082 ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", ddf_dev_get_name(dev)); 1089 1083 return EINVAL; 1090 1084 } 1091 1085 1092 1086 rtl8139->irq = hw_resources->irqs.irqs[0]; 1093 ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", d ev->name, rtl8139->irq);1087 ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", ddf_dev_get_name(dev), rtl8139->irq); 1094 1088 1095 1089 rtl8139->io_addr = IOADDR_TO_PTR(hw_resources->io_ranges.ranges[0].address); 1096 1090 if (hw_resources->io_ranges.ranges[0].size < RTL8139_IO_SIZE) { 1097 1091 ddf_msg(LVL_ERROR, "i/o range assigned to the device " 1098 "%s is too small.", d ev->name);1092 "%s is too small.", ddf_dev_get_name(dev)); 1099 1093 return EINVAL; 1100 1094 } 1101 ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", d ev->name, rtl8139->io_addr);1095 ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", ddf_dev_get_name(dev), rtl8139->io_addr); 1102 1096 1103 1097 return EOK; … … 1167 1161 1168 1162 /* Allocate buffer for receiver */ 1169 ddf_msg(LVL_DEBUG, "Allocating receiver buffer of the size % zubytes",1163 ddf_msg(LVL_DEBUG, "Allocating receiver buffer of the size %d bytes", 1170 1164 RxBUF_TOT_LENGTH); 1171 1165 … … 1194 1188 static int rtl8139_device_initialize(ddf_dev_t *dev) 1195 1189 { 1196 ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", d ev->name);1190 ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", ddf_dev_get_name(dev)); 1197 1191 1198 1192 int ret = EOK; … … 1203 1197 rtl8139_t *rtl8139 = rtl8139_create_dev_data(dev); 1204 1198 if (rtl8139 == NULL) { 1205 ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", d ev->name);1199 ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", ddf_dev_get_name(dev)); 1206 1200 return ENOMEM; 1207 1201 } … … 1248 1242 static int rtl8139_pio_enable(ddf_dev_t *dev) 1249 1243 { 1250 ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", d ev->name);1244 ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", ddf_dev_get_name(dev)); 1251 1245 1252 1246 rtl8139_t *rtl8139 = nic_get_specific(nic_get_from_ddf_dev(dev)); … … 1254 1248 /* Gain control over port's registers. */ 1255 1249 if (pio_enable(rtl8139->io_addr, RTL8139_IO_SIZE, &rtl8139->io_port)) { 1256 ddf_msg(LVL_ERROR, "Cannot gain the port % lxfor device %s.", rtl8139->io_addr,1257 d ev->name);1250 ddf_msg(LVL_ERROR, "Cannot gain the port %p for device %s.", rtl8139->io_addr, 1251 ddf_dev_get_name(dev)); 1258 1252 return EADDRNOTAVAIL; 1259 1253 } … … 1301 1295 1302 1296 assert(dev); 1303 ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %d)", dev->name, dev->handle); 1297 ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %zu)", 1298 ddf_dev_get_name(dev), ddf_dev_get_handle(dev)); 1304 1299 1305 1300 /* Init device structure for rtl8139 */ … … 1332 1327 rc = nic_connect_to_services(nic_data); 1333 1328 if (rc != EOK) { 1334 ddf_msg(LVL_ERROR, "Failed to connect to services ", rc);1329 ddf_msg(LVL_ERROR, "Failed to connect to services (%d)", rc); 1335 1330 goto err_irq; 1336 1331 } … … 1342 1337 } 1343 1338 nic_set_ddf_fun(nic_data, fun); 1344 fun->ops = &rtl8139_dev_ops;1345 fun->driver_data = nic_data;1339 ddf_fun_set_ops(fun, &rtl8139_dev_ops); 1340 ddf_fun_data_implant(fun, nic_data); 1346 1341 1347 1342 rc = ddf_fun_bind(fun); … … 1357 1352 1358 1353 ddf_msg(LVL_NOTE, "The %s device has been successfully initialized.", 1359 d ev->name);1354 ddf_dev_get_name(dev)); 1360 1355 1361 1356 return EOK; … … 2143 2138 pio_write_32(rtl8139->io_port + TCTR, 0); 2144 2139 2145 ddf_msg(LVL_DEBUG, "Periodic mode. Interrupt mask %"PRIx16", poll.full_skips %" 2146 PRIu32", last timer %"PRIu32".", rtl8139->int_mask, 2147 rtl8139->poll_timer.full_skips, rtl8139->poll_timer.last_val); 2140 ddf_msg(LVL_DEBUG, "Periodic mode. Interrupt mask %" PRIx16 ", " 2141 "poll.full_skips %zu, last timer %" PRIu32, 2142 rtl8139->int_mask, rtl8139->poll_timer.full_skips, 2143 rtl8139->poll_timer.last_val); 2148 2144 break; 2149 2145 default: … … 2190 2186 &rtl8139_driver_ops, &rtl8139_dev_ops, &rtl8139_nic_iface); 2191 2187 2192 ddf_log_init(NAME , LVL_ERROR);2188 ddf_log_init(NAME); 2193 2189 ddf_msg(LVL_NOTE, "HelenOS RTL8139 driver started"); 2194 2190 return ddf_driver_main(&rtl8139_driver);
Note:
See TracChangeset
for help on using the changeset viewer.