Changeset d51838f in mainline for uspace/drv/nic


Ignore:
Timestamp:
2017-10-14T22:49:18Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
75911d24
Parents:
ce732e74
Message:

Let leaf drivers enable/disable/clear interrupts via hw_res instead of directly using irc.

Location:
uspace/drv/nic
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/e1k/e1k.c

    rce732e74 rd51838f  
    4040#include <thread.h>
    4141#include <byteorder.h>
    42 #include <irc.h>
    4342#include <as.h>
    4443#include <ddi.h>
    4544#include <ddf/log.h>
    4645#include <ddf/interrupt.h>
     46#include <device/hw_res.h>
    4747#include <device/hw_res_parsed.h>
    4848#include <pci_dev_iface.h>
     
    116116/** E1000 device data */
    117117typedef struct {
     118        /** DDF device */
     119        ddf_dev_t *dev;
     120        /** Parent session */
     121        async_sess_t *parent_sess;
    118122        /** Device configuration */
    119123        e1000_info_t info;
     
    17571761        e1000_enable_interrupts(e1000);
    17581762       
    1759         int rc = irc_enable_interrupt(e1000->irq);
     1763        int rc = hw_res_enable_interrupt(e1000->parent_sess, e1000->irq);
    17601764        if (rc != EOK) {
    17611765                e1000_disable_interrupts(e1000);
     
    18021806        e1000_disable_rx(e1000);
    18031807       
    1804         irc_disable_interrupt(e1000->irq);
     1808        hw_res_disable_interrupt(e1000->parent_sess, e1000->irq);
    18051809        e1000_disable_interrupts(e1000);
    18061810       
     
    18841888       
    18851889        memset(e1000, 0, sizeof(e1000_t));
     1890        e1000->dev = dev;
    18861891       
    18871892        nic_set_specific(nic, e1000);
     
    19982003                ddf_msg(LVL_ERROR, "Unable to allocate device softstate");
    19992004                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;
    20002011        }
    20012012       
     
    21192130{
    21202131        ddf_fun_t *fun;
    2121         assert(dev);
    21222132       
    21232133        /* Initialize device structure for E1000 */
  • uspace/drv/nic/ne2k/dp8390.h

    rce732e74 rd51838f  
    5050#define __NET_NETIF_DP8390_H__
    5151
     52#include <async.h>
     53#include <ddf/driver.h>
    5254#include <fibril_synch.h>
    5355#include <nic.h>
     
    223225
    224226typedef struct {
     227        /** DDF device */
     228        ddf_dev_t *dev;
     229        /** Parent session */
     230        async_sess_t *parent_sess;
    225231        /* Device configuration */
    226232        void *base_port; /**< Port assigned from ISA configuration **/
  • uspace/drv/nic/ne2k/ne2k.c

    rce732e74 rd51838f  
    4040#include <stdio.h>
    4141#include <errno.h>
    42 #include <irc.h>
     42#include <device/hw_res.h>
    4343#include <stdlib.h>
    4444#include <str_error.h>
     
    256256                        return rc;
    257257
    258                 rc = irc_enable_interrupt(ne2k->irq);
     258                rc = hw_res_enable_interrupt(ne2k->parent_sess, ne2k->irq);
    259259                if (rc != EOK) {
    260260                        ne2k_down(ne2k);
     
    269269        ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
    270270
    271         (void) irc_disable_interrupt(ne2k->irq);
     271        (void) hw_res_disable_interrupt(ne2k->parent_sess, ne2k->irq);
    272272        ne2k->receive_configuration = RCR_AB | RCR_AM;
    273273        ne2k_down(ne2k);
     
    384384        }
    385385       
     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       
    386393        int rc = ne2k_dev_init(nic_data);
    387394        if (rc != EOK) {
  • uspace/drv/nic/rtl8139/driver.c

    rce732e74 rd51838f  
    3636#include <ddf/log.h>
    3737#include <ddf/interrupt.h>
     38#include <device/hw_res.h>
    3839#include <io/log.h>
    3940#include <nic.h>
    4041#include <pci_dev_iface.h>
    41 #include <irc.h>
    4242#include <stdio.h>
    4343#include <str.h>
     
    920920        rtl8139_hw_int_set(rtl8139);
    921921
    922         int rc = irc_enable_interrupt(rtl8139->irq);
     922        int rc = hw_res_enable_interrupt(rtl8139->parent_sess, rtl8139->irq);
    923923        if (rc != EOK) {
    924924                rtl8139_on_stopped(nic_data);
     
    976976                return NULL;
    977977
    978         rtl8139_t *rtl8139 = malloc(sizeof(rtl8139_t));
     978        rtl8139_t *rtl8139 = calloc(1, sizeof(rtl8139_t));
    979979        if (!rtl8139) {
    980980                nic_unbind_and_destroy(dev);
     
    982982        }
    983983
    984         memset(rtl8139, 0, sizeof(rtl8139_t));
     984        rtl8139->dev = dev;
    985985
    986986        rtl8139->nic_data = nic_data;
     
    11661166
    11671167        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        }
    11681173
    11691174        /* Obtain and fill hardware resources info and connect to parent */
     
    12581263        ddf_fun_t *fun;
    12591264
    1260         assert(dev);
    12611265        ddf_msg(LVL_NOTE, "RTL8139_dev_add %s (handle = %zu)",
    12621266            ddf_dev_get_name(dev), ddf_dev_get_handle(dev));
  • uspace/drv/nic/rtl8139/driver.h

    rce732e74 rd51838f  
    8787/** RTL8139 device data */
    8888typedef struct rtl8139_data {
     89        /** DDF device */
     90        ddf_dev_t *dev;
     91        /** Parent session */
     92        async_sess_t *parent_sess;
    8993        /** I/O address of the device */
    9094        void *io_addr;
  • uspace/drv/nic/rtl8169/driver.c

    rce732e74 rd51838f  
    3131#include <align.h>
    3232#include <byteorder.h>
    33 #include <irc.h>
    3433#include <libarch/barrier.h>
    3534
     
    3837#include <ddf/log.h>
    3938#include <ddf/interrupt.h>
     39#include <device/hw_res.h>
     40#include <device/hw_res_parsed.h>
    4041#include <io/log.h>
    4142#include <nic.h>
    4243#include <pci_dev_iface.h>
    4344
    44 #include <ipc/irc.h>
    4545#include <sysinfo.h>
    4646#include <ipc/ns.h>
     
    396396        rtl8169_t *rtl8169 = nic_get_specific(nic_data);
    397397
     398        rtl8169->dev = dev;
     399        rtl8169->parent_sess = ddf_dev_parent_sess_get(dev);
     400        if (rtl8169->parent_sess == NULL)
     401                return EIO;
     402
    398403        /* 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);
    401406        if (rc != EOK)
    402407                return rc;
    403408
    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);
    406411        if (rc != EOK)
    407412                return rc;
     
    745750
    746751        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);
    748754
    749755        return EOK;
  • uspace/drv/nic/rtl8169/driver.h

    rce732e74 rd51838f  
    4949/** RTL8139 device data */
    5050typedef struct rtl8169_data {
     51        /** DDF device */
     52        ddf_dev_t *dev;
     53        /** Parent session */
     54        async_sess_t *parent_sess;
    5155        /** I/O address of the device */
    5256        void *regs_phys;
Note: See TracChangeset for help on using the changeset viewer.