Changeset 15d0046 in mainline for uspace/drv/nic/rtl8139/driver.c


Ignore:
Timestamp:
2014-09-12T13:22:33Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9b20126
Parents:
8db09e4 (diff), 105d8d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

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

    r8db09e4 r15d0046  
    2727 */
    2828
    29 /* XXX Fix this */
    30 #define _DDF_DATA_IMPLANT
    31 
    3229#include <assert.h>
    3330#include <errno.h>
     
    3532#include <byteorder.h>
    3633#include <libarch/barrier.h>
    37 
    3834#include <as.h>
    3935#include <ddf/log.h>
     
    4238#include <nic.h>
    4339#include <pci_dev_iface.h>
    44 
    45 #include <ipc/irc.h>
    46 #include <sysinfo.h>
    47 #include <ipc/ns.h>
    48 
     40#include <irc.h>
     41#include <stdio.h>
    4942#include <str.h>
    5043
     
    859852/** Handle device interrupt
    860853 *
    861  *  @param dev    The rtl8139 device
    862  *  @param iid    The IPC call id
    863  *  @param icall  The IPC call structure
    864  */
    865 static void rtl8139_interrupt_handler(ddf_dev_t *dev, ipc_callid_t iid,
    866     ipc_call_t *icall)
     854 * @param iid    The IPC call id
     855 * @param icall  The IPC call structure
     856 * @param dev    The rtl8139 device
     857 *
     858 */
     859static void rtl8139_interrupt_handler(ipc_callid_t iid, ipc_call_t *icall,
     860    ddf_dev_t *dev)
    867861{
    868862        assert(dev);
     
    960954        rtl8139->int_mask = RTL_DEFAULT_INTERRUPTS;
    961955        rtl8139_hw_int_enable(rtl8139);
    962         nic_enable_interrupt(nic_data, rtl8139->irq);
     956
     957        int rc = irc_enable_interrupt(rtl8139->irq);
     958        if (rc != EOK) {
     959                rtl8139_on_stopped(nic_data);
     960                return rc;
     961        }
    963962
    964963        ddf_msg(LVL_DEBUG, "Device activated, interrupt %d registered", rtl8139->irq);
     
    11411140
    11421141        ddf_msg(LVL_DEBUG, "Creating buffers");
    1143 
     1142       
     1143        rtl8139->tx_buff_virt = AS_AREA_ANY;
    11441144        rc = dmamem_map_anonymous(TX_PAGES * PAGE_SIZE, DMAMEM_4GiB,
    11451145            AS_AREA_WRITE, 0, &rtl8139->tx_buff_phys, &rtl8139->tx_buff_virt);
     
    11611161        ddf_msg(LVL_DEBUG, "Allocating receiver buffer of the size %d bytes",
    11621162            RxBUF_TOT_LENGTH);
    1163 
     1163       
     1164        rtl8139->rx_buff_virt = AS_AREA_ANY;
    11641165        rc = dmamem_map_anonymous(RxBUF_TOT_LENGTH, DMAMEM_4GiB,
    11651166            AS_AREA_READ, 0, &rtl8139->rx_buff_phys, &rtl8139->rx_buff_virt);
     
    13231324                goto err_pio;
    13241325
    1325         rc = nic_connect_to_services(nic_data);
    1326         if (rc != EOK) {
    1327                 ddf_msg(LVL_ERROR, "Failed to connect to services (%d)", rc);
    1328                 goto err_irq;
    1329         }
    1330 
    13311326        fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0");
    13321327        if (fun == NULL) {
     
    13341329                goto err_srv;
    13351330        }
     1331
    13361332        nic_set_ddf_fun(nic_data, fun);
    13371333        ddf_fun_set_ops(fun, &rtl8139_dev_ops);
    1338         ddf_fun_data_implant(fun, nic_data);
    13391334
    13401335        rc = ddf_fun_bind(fun);
     
    13591354        ddf_fun_destroy(fun);
    13601355err_srv:
    1361         /* XXX Disconnect from services */
    1362 err_irq:
    13631356        unregister_interrupt_handler(dev, rtl8139->irq);
    13641357err_pio:
     
    21782171int main(void)
    21792172{
     2173        printf("%s: HelenOS RTL8139 network adapter driver\n", NAME);
     2174
    21802175        int rc = nic_driver_init(NAME);
    21812176        if (rc != EOK)
    21822177                return rc;
    2183         nic_driver_implement(
    2184                 &rtl8139_driver_ops, &rtl8139_dev_ops, &rtl8139_nic_iface);
     2178
     2179        nic_driver_implement(&rtl8139_driver_ops, &rtl8139_dev_ops,
     2180            &rtl8139_nic_iface);
    21852181
    21862182        ddf_log_init(NAME);
    2187         ddf_msg(LVL_NOTE, "HelenOS RTL8139 driver started");
    21882183        return ddf_driver_main(&rtl8139_driver);
    21892184}
Note: See TracChangeset for help on using the changeset viewer.