Ignore:
File:
1 edited

Legend:

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

    r9d58539 r1ae74c6  
    2727 */
    2828
     29/* XXX Fix this */
     30#define _DDF_DATA_IMPLANT
     31
    2932#include <assert.h>
    3033#include <errno.h>
    3134#include <align.h>
    3235#include <byteorder.h>
    33 #include <libarch/ddi.h>
    3436#include <libarch/barrier.h>
    3537
     
    4446#include <sysinfo.h>
    4547#include <ipc/ns.h>
    46 
    47 #include <net_checksum.h>
    4848
    4949#include <str.h>
     
    214214        rtl8139_regs_lock(rtl8139->io_port);
    215215
     216        async_sess_t *pci_sess =
     217                ddf_dev_parent_sess_get(nic_get_ddf_dev(rtl8139->nic_data));
     218
    216219        if (bit_val) {
    217                 async_sess_t *pci_sess =
    218                         nic_get_ddf_dev(rtl8139->nic_data)->parent_sess;
    219220                uint8_t pmen;
    220221                pci_config_space_read_8(pci_sess, 0x55, &pmen);
    221222                pci_config_space_write_8(pci_sess, 0x55, pmen | 1 | (1 << 7));
    222223        } else {
    223                 async_sess_t *pci_sess =
    224                         nic_get_ddf_dev(rtl8139->nic_data)->parent_sess;
    225224                uint8_t pmen;
    226225                pci_config_space_read_8(pci_sess, 0x55, &pmen);
     
    620619                /* Check if the header is valid, otherwise we are lost in the buffer */
    621620                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,
    624623                            rx_offset);
    625624                        goto rx_err;
     
    10541053        assert(dev);
    10551054
    1056         if (dev->driver_data)
     1055        if (ddf_dev_data_get(dev))
    10571056                nic_unbind_and_destroy(dev);
    1058 
    1059         if (dev->parent_sess != NULL) {
    1060                 async_hangup(dev->parent_sess);
    1061                 dev->parent_sess = NULL;
    1062         }
    10631057}
    10641058
     
    10821076
    10831077        if (hw_resources->irqs.count != 1) {
    1084                 ddf_msg(LVL_ERROR, "%s device: unexpected irq count", dev->name);
     1078                ddf_msg(LVL_ERROR, "%s device: unexpected irq count", ddf_dev_get_name(dev));
    10851079                return EINVAL;
    10861080        };
    10871081        if (hw_resources->io_ranges.count != 1) {
    1088                 ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", dev->name);
     1082                ddf_msg(LVL_ERROR, "%s device: unexpected io ranges count", ddf_dev_get_name(dev));
    10891083                return EINVAL;
    10901084        }
    10911085
    10921086        rtl8139->irq = hw_resources->irqs.irqs[0];
    1093         ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", dev->name, rtl8139->irq);
     1087        ddf_msg(LVL_DEBUG, "%s device: irq 0x%x assigned", ddf_dev_get_name(dev), rtl8139->irq);
    10941088
    10951089        rtl8139->io_addr = IOADDR_TO_PTR(hw_resources->io_ranges.ranges[0].address);
    10961090        if (hw_resources->io_ranges.ranges[0].size < RTL8139_IO_SIZE) {
    10971091                ddf_msg(LVL_ERROR, "i/o range assigned to the device "
    1098                     "%s is too small.", dev->name);
     1092                    "%s is too small.", ddf_dev_get_name(dev));
    10991093                return EINVAL;
    11001094        }
    1101         ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", dev->name, rtl8139->io_addr);
     1095        ddf_msg(LVL_DEBUG, "%s device: i/o addr %p assigned.", ddf_dev_get_name(dev), rtl8139->io_addr);
    11021096
    11031097        return EOK;
     
    11671161
    11681162        /* Allocate buffer for receiver */
    1169         ddf_msg(LVL_DEBUG, "Allocating receiver buffer of the size %zu bytes",
     1163        ddf_msg(LVL_DEBUG, "Allocating receiver buffer of the size %d bytes",
    11701164            RxBUF_TOT_LENGTH);
    11711165
     
    11941188static int rtl8139_device_initialize(ddf_dev_t *dev)
    11951189{
    1196         ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", dev->name);
     1190        ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", ddf_dev_get_name(dev));
    11971191
    11981192        int ret = EOK;
     
    12031197        rtl8139_t *rtl8139 = rtl8139_create_dev_data(dev);
    12041198        if (rtl8139 == NULL) {
    1205                 ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", dev->name);
     1199                ddf_msg(LVL_ERROR, "Not enough memory for initializing %s.", ddf_dev_get_name(dev));
    12061200                return ENOMEM;
    12071201        }
     
    12481242static int rtl8139_pio_enable(ddf_dev_t *dev)
    12491243{
    1250         ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", dev->name);
     1244        ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", ddf_dev_get_name(dev));
    12511245
    12521246        rtl8139_t *rtl8139 = nic_get_specific(nic_get_from_ddf_dev(dev));
     
    12541248        /* Gain control over port's registers. */
    12551249        if (pio_enable(rtl8139->io_addr, RTL8139_IO_SIZE, &rtl8139->io_port)) {
    1256                 ddf_msg(LVL_ERROR, "Cannot gain the port %lx for device %s.", rtl8139->io_addr,
    1257                     dev->name);
     1250                ddf_msg(LVL_ERROR, "Cannot gain the port %p for device %s.", rtl8139->io_addr,
     1251                    ddf_dev_get_name(dev));
    12581252                return EADDRNOTAVAIL;
    12591253        }
     
    13011295
    13021296        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));
    13041299
    13051300        /* Init device structure for rtl8139 */
     
    13321327        rc = nic_connect_to_services(nic_data);
    13331328        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);
    13351330                goto err_irq;
    13361331        }
     
    13421337        }
    13431338        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);
    13461341
    13471342        rc = ddf_fun_bind(fun);
     
    13571352
    13581353        ddf_msg(LVL_NOTE, "The %s device has been successfully initialized.",
    1359             dev->name);
     1354            ddf_dev_get_name(dev));
    13601355
    13611356        return EOK;
     
    21432138                pio_write_32(rtl8139->io_port + TCTR, 0);
    21442139
    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);
    21482144                break;
    21492145        default:
     
    21902186                &rtl8139_driver_ops, &rtl8139_dev_ops, &rtl8139_nic_iface);
    21912187
    2192         ddf_log_init(NAME, LVL_ERROR);
     2188        ddf_log_init(NAME);
    21932189        ddf_msg(LVL_NOTE, "HelenOS RTL8139 driver started");
    21942190        return ddf_driver_main(&rtl8139_driver);
Note: See TracChangeset for help on using the changeset viewer.