Changeset 869d936 in mainline


Ignore:
Timestamp:
2014-07-18T08:11:34Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e5424e9
Parents:
fc6abbe
Message:

libnic slices, dices, cooks cofee and enables interrupts.

Location:
uspace
Files:
2 added
8 edited

Legend:

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

    rfc6abbe r869d936  
    4242#include <align.h>
    4343#include <byteorder.h>
    44 #include <sysinfo.h>
    45 #include <ipc/irc.h>
    46 #include <ipc/ns.h>
     44#include <irc.h>
     45#include <as.h>
    4746#include <ddi.h>
    48 #include <as.h>
    4947#include <ddf/log.h>
    5048#include <ddf/interrupt.h>
     
    17581756        e1000_enable_interrupts(e1000);
    17591757       
    1760         nic_enable_interrupt(nic, e1000->irq);
     1758        irc_enable_interrupt(e1000->irq);
    17611759       
    17621760        e1000_clear_rx_ring(e1000);
     
    17961794        e1000_disable_rx(e1000);
    17971795       
    1798         nic_disable_interrupt(nic, e1000->irq);
     1796        irc_disable_interrupt(e1000->irq);
    17991797        e1000_disable_interrupts(e1000);
    18001798       
     
    21532151        if (rc != EOK)
    21542152                goto err_fun_create;
    2155        
    2156         rc = nic_connect_to_services(nic);
    2157         if (rc != EOK)
    2158                 goto err_irq;
    21592153       
    21602154        rc = e1000_initialize_rx_structure(nic);
     
    23792373int main(void)
    23802374{
    2381         int rc = nic_driver_init(NAME);
    2382         if (rc != EOK)
    2383                 return rc;
     2375        printf("%s: HelenOS E1000 network adapter driver\n", NAME);
     2376       
     2377        if (irc_init() != EOK) {
     2378                printf("%s: Failed connecting IRC service\n", NAME);
     2379                return 1;
     2380        }
     2381       
     2382        if (nic_driver_init(NAME) != EOK)
     2383                return 1;
    23842384       
    23852385        nic_driver_implement(&e1000_driver_ops, &e1000_dev_ops,
     
    23872387       
    23882388        ddf_log_init(NAME);
    2389         ddf_msg(LVL_NOTE, "HelenOS E1000 driver started");
    23902389        return ddf_driver_main(&e1000_driver);
    23912390}
  • uspace/drv/nic/ne2k/ne2k.c

    rfc6abbe r869d936  
    4343#include <stdio.h>
    4444#include <errno.h>
     45#include <irc.h>
    4546#include <stdlib.h>
    4647#include <str_error.h>
     
    260261                }
    261262
    262                 nic_enable_interrupt(nic_data, ne2k->irq);
     263                irc_enable_interrupt(ne2k->irq);
    263264        }
    264265        return EOK;
     
    269270        ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
    270271
    271         nic_disable_interrupt(nic_data, ne2k->irq);
     272        irc_disable_interrupt(ne2k->irq);
    272273        ne2k->receive_configuration = RCR_AB | RCR_AM;
    273274        ne2k_down(ne2k);
     
    396397        }
    397398       
    398         rc = nic_connect_to_services(nic_data);
    399         if (rc != EOK) {
    400                 ne2k_dev_cleanup(dev);
    401                 return rc;
    402         }
    403        
    404399        fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0");
    405400        if (fun == NULL) {
     
    443438int main(int argc, char *argv[])
    444439{
     440        printf("%s: HelenOS NE 2000 network adapter driver\n", NAME);
     441       
     442        if (irc_init() != EOK) {
     443                printf("%s: Failed connecting IRC service\n", NAME);
     444                return 1;
     445        }
     446       
    445447        nic_driver_init(NAME);
    446448        nic_driver_implement(&ne2k_driver_ops, &ne2k_dev_ops, &ne2k_nic_iface);
  • uspace/drv/nic/rtl8139/driver.c

    rfc6abbe r869d936  
    3535#include <byteorder.h>
    3636#include <libarch/barrier.h>
    37 
    3837#include <as.h>
    3938#include <ddf/log.h>
     
    4241#include <nic.h>
    4342#include <pci_dev_iface.h>
    44 
    45 #include <ipc/irc.h>
    46 #include <sysinfo.h>
    47 #include <ipc/ns.h>
    48 
     43#include <irc.h>
     44#include <stdio.h>
    4945#include <str.h>
    5046
     
    960956        rtl8139->int_mask = RTL_DEFAULT_INTERRUPTS;
    961957        rtl8139_hw_int_enable(rtl8139);
    962         nic_enable_interrupt(nic_data, rtl8139->irq);
     958        irc_enable_interrupt(rtl8139->irq);
    963959
    964960        ddf_msg(LVL_DEBUG, "Device activated, interrupt %d registered", rtl8139->irq);
     
    13251321                goto err_pio;
    13261322
    1327         rc = nic_connect_to_services(nic_data);
    1328         if (rc != EOK) {
    1329                 ddf_msg(LVL_ERROR, "Failed to connect to services (%d)", rc);
    1330                 goto err_irq;
    1331         }
    1332 
    13331323        fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0");
    13341324        if (fun == NULL) {
     
    13611351        ddf_fun_destroy(fun);
    13621352err_srv:
    1363         /* XXX Disconnect from services */
    1364 err_irq:
    13651353        unregister_interrupt_handler(dev, rtl8139->irq);
    13661354err_pio:
     
    21802168int main(void)
    21812169{
     2170        printf("%s: HelenOS RTL8139 network adapter driver\n", NAME);
     2171
     2172        if (irc_init() != EOK) {
     2173                printf("%s: Failed connecting IRC service\n", NAME);
     2174                return 1;
     2175        }
     2176
    21822177        int rc = nic_driver_init(NAME);
    21832178        if (rc != EOK)
    21842179                return rc;
    2185         nic_driver_implement(
    2186                 &rtl8139_driver_ops, &rtl8139_dev_ops, &rtl8139_nic_iface);
     2180
     2181        nic_driver_implement(&rtl8139_driver_ops, &rtl8139_dev_ops,
     2182            &rtl8139_nic_iface);
    21872183
    21882184        ddf_log_init(NAME);
    2189         ddf_msg(LVL_NOTE, "HelenOS RTL8139 driver started");
    21902185        return ddf_driver_main(&rtl8139_driver);
    21912186}
  • uspace/lib/c/Makefile

    rfc6abbe r869d936  
    109109        generic/iplink.c \
    110110        generic/iplink_srv.c \
     111        generic/irc.c \
    111112        generic/ieee_double.c \
    112113        generic/power_of_ten.c \
  • uspace/lib/c/include/ipc/irc.h

    rfc6abbe r869d936  
    3333 */
    3434
    35 #ifndef LIBC_IRC_H_
    36 #define LIBC_IRC_H_
     35#ifndef LIBC_IPC_IRC_H_
     36#define LIBC_IPC_IRC_H_
    3737
    3838#include <ipc/common.h>
  • uspace/lib/nic/include/nic.h

    rfc6abbe r869d936  
    216216
    217217/* Functions called in add_device */
    218 extern int nic_connect_to_services(nic_t *);
    219218extern int nic_get_resources(nic_t *, hw_res_list_parsed_t *);
    220219extern void nic_set_specific(nic_t *, void *);
     
    245244extern void nic_received_frame(nic_t *, nic_frame_t *);
    246245extern void nic_received_frame_list(nic_t *, nic_frame_list_t *);
    247 extern void nic_disable_interrupt(nic_t *, int);
    248 extern void nic_enable_interrupt(nic_t *, int);
    249246extern nic_poll_mode_t nic_query_poll_mode(nic_t *, struct timeval *);
    250247
  • uspace/lib/nic/include/nic_driver.h

    rfc6abbe r869d936  
    8080        /** Client callback session */
    8181        async_sess_t *client_session;
    82         /** Phone to APIC or i8259 */
    83         async_sess_t *irc_session;
    8482        /** Current polling mode of the NIC */
    8583        nic_poll_mode_t poll_mode;
  • uspace/lib/nic/src/nic_driver.c

    rfc6abbe r869d936  
    4242#include <stdio.h>
    4343#include <str_error.h>
    44 #include <ipc/services.h>
    45 #include <ipc/ns.h>
    46 #include <ipc/irc.h>
    4744#include <sysinfo.h>
    4845#include <as.h>
     
    378375}
    379376
    380 
    381 /**
    382  * Enable interrupts for this driver.
    383  *
    384  * @param nic_data
    385  * @param irq                   The IRQ number for this device
    386  */
    387 void nic_enable_interrupt(nic_t *nic_data, int irq)
    388 {
    389         async_exch_t *exch = async_exchange_begin(nic_data->irc_session);
    390         async_msg_1(exch, IRC_ENABLE_INTERRUPT, irq);
    391         async_exchange_end(exch);
    392 }
    393 
    394 /**
    395  * Disable interrupts for this driver.
    396  *
    397  * @param nic_data
    398  * @param irq                   The IRQ number for this device
    399  */
    400 void nic_disable_interrupt(nic_t *nic_data, int irq)
    401 {
    402         async_exch_t *exch = async_exchange_begin(nic_data->irc_session);
    403         async_msg_1(exch, IRC_CLEAR_INTERRUPT, irq);
    404         async_exchange_end(exch);
    405 }
    406 
    407377/** Get the polling mode information from the device
    408378 *
     
    420390        return nic_data->poll_mode;
    421391};
    422 
    423 /**
    424  * Connect to IRC service. This function should be called only from
    425  * the add_device handler, thus no locking is required.
    426  *
    427  * @param nic_data
    428  *
    429  * @return EOK          If connection was successful.
    430  * @return EINVAL       If the IRC service cannot be determined.
    431  * @return EREFUSED     If IRC service cannot be connected.
    432  */
    433 int nic_connect_to_services(nic_t *nic_data)
    434 {
    435         /* IRC service */
    436         sysarg_t apic;
    437         sysarg_t i8259;
    438         services_t irc_service = -1;
    439         if (((sysinfo_get_value("apic", &apic) == EOK) && (apic)) ||
    440             ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259)))
    441                 irc_service = SERVICE_IRC;
    442         else
    443                 return EINVAL;
    444        
    445         nic_data->irc_session = service_connect_blocking(EXCHANGE_SERIALIZE,
    446                 irc_service, 0, 0);
    447         if (nic_data->irc_session == NULL)
    448                 return errno;
    449        
    450         return EOK;
    451 }
    452392
    453393/** Inform the NICF about poll mode
     
    668608        nic_data->state = NIC_STATE_STOPPED;
    669609        nic_data->client_session = NULL;
    670         nic_data->irc_session = NULL;
    671610        nic_data->poll_mode = NIC_POLL_IMMEDIATE;
    672611        nic_data->default_poll_mode = NIC_POLL_IMMEDIATE;
Note: See TracChangeset for help on using the changeset viewer.