Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/netif/ne2000/ne2000.c

    rffa2c8ef ree2fa30a  
    4343#include <malloc.h>
    4444#include <sysinfo.h>
     45#include <ns.h>
    4546#include <ipc/services.h>
    46 #include <ipc/ns.h>
    4747#include <ipc/irc.h>
    4848#include <net/modules.h>
     
    7575#define IRQ_GET_TSR(call)  ((int) IPC_GET_ARG3(call))
    7676
    77 static int irc_service = 0;
    78 static int irc_phone = -1;
     77static bool irc_service = false;
     78static async_sess_t *irc_sess = NULL;
    7979
    8080/** NE2000 kernel interrupt command sequence.
     
    152152        device_id_t device_id = IRQ_GET_DEVICE(*call);
    153153        netif_device_t *device;
    154         int nil_phone;
     154        async_sess_t *nil_sess;
    155155        ne2k_t *ne2k;
    156156       
    157157        fibril_rwlock_read_lock(&netif_globals.lock);
    158158       
    159         if (find_device(device_id, &device) == EOK) {
    160                 nil_phone = device->nil_phone;
     159        nil_sess = netif_globals.nil_sess;
     160       
     161        if (find_device(device_id, &device) == EOK)
    161162                ne2k = (ne2k_t *) device->specific;
    162         } else
     163        else
    163164                ne2k = NULL;
    164165       
     
    166167       
    167168        if (ne2k != NULL) {
    168                 link_t *frames =
     169                list_t *frames =
    169170                    ne2k_interrupt(ne2k, IRQ_GET_ISR(*call), IRQ_GET_TSR(*call));
    170171               
    171172                if (frames != NULL) {
    172173                        while (!list_empty(frames)) {
    173                                 frame_t *frame =
    174                                     list_get_instance(frames->next, frame_t, link);
     174                                frame_t *frame = list_get_instance(
     175                                    list_first(frames), frame_t, link);
    175176                               
    176177                                list_remove(&frame->link);
    177                                 nil_received_msg(nil_phone, device_id, frame->packet,
     178                                nil_received_msg(nil_sess, device_id, frame->packet,
    178179                                    SERVICE_NONE);
    179180                                free(frame);
     
    276277       
    277278        device->device_id = device_id;
    278         device->nil_phone = -1;
    279279        device->specific = (void *) ne2k;
    280280        device->state = NETIF_STOPPED;
     
    329329                change_state(device, NETIF_ACTIVE);
    330330               
    331                 if (irc_service)
    332                         async_msg_1(irc_phone, IRC_ENABLE_INTERRUPT, ne2k->irq);
     331                if (irc_service) {
     332                        async_exch_t *exch = async_exchange_begin(irc_sess);
     333                        async_msg_1(exch, IRC_ENABLE_INTERRUPT, ne2k->irq);
     334                        async_exchange_end(exch);
     335                }
    333336        }
    334337       
     
    383386        sysarg_t i8259;
    384387       
    385         if ((sysinfo_get_value("apic", &apic) == EOK) && (apic))
    386                 irc_service = SERVICE_APIC;
    387         else if ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))
    388                 irc_service = SERVICE_I8259;
     388        if (((sysinfo_get_value("apic", &apic) == EOK) && (apic))
     389            || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259)))
     390                irc_service = true;
    389391       
    390392        if (irc_service) {
    391                 while (irc_phone < 0)
    392                         irc_phone = service_connect_blocking(irc_service, 0, 0);
     393                while (!irc_sess)
     394                        irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     395                            SERVICE_IRC, 0, 0);
    393396        }
    394397       
    395398        async_set_interrupt_received(irq_handler);
    396399       
    397         return async_connect_to_me(PHONE_NS, SERVICE_NE2000, 0, 0, NULL);
     400        return service_register(SERVICE_NE2000);
    398401}
    399402
Note: See TracChangeset for help on using the changeset viewer.