Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/rtl8139/driver.c

    r56fd7cf r9d58539  
    2727 */
    2828
    29 /* XXX Fix this */
    30 #define _DDF_DATA_IMPLANT
    31 
    3229#include <assert.h>
    3330#include <errno.h>
     
    4744#include <sysinfo.h>
    4845#include <ipc/ns.h>
     46
     47#include <net_checksum.h>
    4948
    5049#include <str.h>
     
    215214        rtl8139_regs_lock(rtl8139->io_port);
    216215
    217         async_sess_t *pci_sess =
    218                 ddf_dev_parent_sess_get(nic_get_ddf_dev(rtl8139->nic_data));
    219 
    220216        if (bit_val) {
     217                async_sess_t *pci_sess =
     218                        nic_get_ddf_dev(rtl8139->nic_data)->parent_sess;
    221219                uint8_t pmen;
    222220                pci_config_space_read_8(pci_sess, 0x55, &pmen);
    223221                pci_config_space_write_8(pci_sess, 0x55, pmen | 1 | (1 << 7));
    224222        } else {
     223                async_sess_t *pci_sess =
     224                        nic_get_ddf_dev(rtl8139->nic_data)->parent_sess;
    225225                uint8_t pmen;
    226226                pci_config_space_read_8(pci_sess, 0x55, &pmen);
     
    10541054        assert(dev);
    10551055
    1056         if (ddf_dev_data_get(dev))
     1056        if (dev->driver_data)
    10571057                nic_unbind_and_destroy(dev);
     1058
     1059        if (dev->parent_sess != NULL) {
     1060                async_hangup(dev->parent_sess);
     1061                dev->parent_sess = NULL;
     1062        }
    10581063}
    10591064
     
    10771082
    10781083        if (hw_resources->irqs.count != 1) {
    1079                 ddf_msg(LVL_ERROR, "%s device: unexpected irq count", ddf_dev_get_name(dev));
     1084                ddf_msg(LVL_ERROR, "%s device: unexpected irq count", dev->name);
    10801085                return EINVAL;
    10811086        };
    10821087        if (hw_resources->io_ranges.count != 1) {
    1083                 ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", ddf_dev_get_name(dev));
     1088                ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", dev->name);
    10841089                return EINVAL;
    10851090        }
    10861091
    10871092        rtl8139->irq = hw_resources->irqs.irqs[0];
    1088         ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", ddf_dev_get_name(dev), rtl8139->irq);
     1093        ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", dev->name, rtl8139->irq);
    10891094
    10901095        rtl8139->io_addr = IOADDR_TO_PTR(hw_resources->io_ranges.ranges[0].address);
    10911096        if (hw_resources->io_ranges.ranges[0].size < RTL8139_IO_SIZE) {
    10921097                ddf_msg(LVL_ERROR, "i/o range assigned to the device "
    1093                     "%s is too small.", ddf_dev_get_name(dev));
     1098                    "%s is too small.", dev->name);
    10941099                return EINVAL;
    10951100        }
    1096         ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", ddf_dev_get_name(dev), rtl8139->io_addr);
     1101        ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", dev->name, rtl8139->io_addr);
    10971102
    10981103        return EOK;
     
    11891194static int rtl8139_device_initialize(ddf_dev_t *dev)
    11901195{
    1191         ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", ddf_dev_get_name(dev));
     1196        ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", dev->name);
    11921197
    11931198        int ret = EOK;
     
    11981203        rtl8139_t *rtl8139 = rtl8139_create_dev_data(dev);
    11991204        if (rtl8139 == NULL) {
    1200                 ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", ddf_dev_get_name(dev));
     1205                ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", dev->name);
    12011206                return ENOMEM;
    12021207        }
     
    12431248static int rtl8139_pio_enable(ddf_dev_t *dev)
    12441249{
    1245         ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", ddf_dev_get_name(dev));
     1250        ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", dev->name);
    12461251
    12471252        rtl8139_t *rtl8139 = nic_get_specific(nic_get_from_ddf_dev(dev));
     
    12501255        if (pio_enable(rtl8139->io_addr, RTL8139_IO_SIZE, &rtl8139->io_port)) {
    12511256                ddf_msg(LVL_ERROR, "Cannot gain the port %lx for device %s.", rtl8139->io_addr,
    1252                     ddf_dev_get_name(dev));
     1257                    dev->name);
    12531258                return EADDRNOTAVAIL;
    12541259        }
     
    12961301
    12971302        assert(dev);
    1298         ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %d)",
    1299             ddf_dev_get_name(dev), ddf_dev_get_handle(dev));
     1303        ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %d)", dev->name, dev->handle);
    13001304
    13011305        /* Init device structure for rtl8139 */
     
    13381342        }
    13391343        nic_set_ddf_fun(nic_data, fun);
    1340         ddf_fun_set_ops(fun, &rtl8139_dev_ops);
    1341         ddf_fun_data_implant(fun, nic_data);
     1344        fun->ops = &rtl8139_dev_ops;
     1345        fun->driver_data = nic_data;
    13421346
    13431347        rc = ddf_fun_bind(fun);
     
    13531357
    13541358        ddf_msg(LVL_NOTE, "The %s device has been successfully initialized.",
    1355             ddf_dev_get_name(dev));
     1359            dev->name);
    13561360
    13571361        return EOK;
Note: See TracChangeset for help on using the changeset viewer.