Changeset 733a9a8 in mainline for uspace/drv/uhci-hcd/main.c


Ignore:
Timestamp:
2011-02-19T19:45:18Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7e7f0f5
Parents:
e221ca0
Message:

Use hardware interrupts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/main.c

    re221ca0 r733a9a8  
    3434#include <driver.h>
    3535#include <usb_iface.h>
     36#include <ipc/irc.h>
     37#include <ipc/ns.h>
     38#include <ipc/services.h>
     39#include <sysinfo.h>
    3640
    3741#include <errno.h>
     
    7680};
    7781/*----------------------------------------------------------------------------*/
     82static irq_cmd_t uhci_cmds[] = {
     83        {
     84                .cmd = CMD_PIO_READ_16,
     85                .addr = (void*)0xc022,
     86                .dstarg = 1
     87        },
     88        {
     89                .cmd = CMD_PIO_WRITE_16,
     90                .addr = (void*)0xc022,
     91                .value = 0x1f
     92        },
     93        {
     94                .cmd = CMD_ACCEPT
     95        }
     96};
     97/*----------------------------------------------------------------------------*/
     98static irq_code_t uhci_code = {
     99        sizeof(uhci_cmds) / sizeof(irq_cmd_t),
     100        uhci_cmds
     101};
     102/*----------------------------------------------------------------------------*/
    78103static void irq_handler(device_t *device, ipc_callid_t iid, ipc_call_t *call)
    79104{
     
    81106        uhci_t *hc = dev_to_uhci(device);
    82107        usb_log_info("LOL HARDWARE INTERRUPT: %p.\n", hc);
     108        uint16_t status = IPC_GET_ARG1(*call);
    83109        assert(hc);
    84         uhci_interrupt(hc);
     110        uhci_interrupt(hc, status);
    85111}
    86112/*----------------------------------------------------------------------------*/
     
    109135            io_reg_base, io_reg_size, irq);
    110136
    111         ret = register_interrupt_handler(device, irq, irq_handler, NULL);
     137
     138  sysarg_t apic;
     139  sysarg_t i8259;
     140        int irc_phone = -1;
     141        int irc_service = 0;
     142
     143  if ((sysinfo_get_value("apic", &apic) == EOK) && (apic)) {
     144    irc_service = SERVICE_APIC;
     145                usb_log_debug("SERVICE_APIC\n");
     146        } else if ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259)) {
     147    irc_service = SERVICE_I8259;
     148                usb_log_debug("SERVICE_I8259\n");
     149        }
     150
     151  if (irc_service) {
     152    while (irc_phone < 0)
     153      irc_phone = service_connect_blocking(irc_service, 0, 0);
     154  }
     155        usb_log_debug("Interrupt conttroller phone: %d\n", irc_phone);
     156
     157        async_msg_1(irc_phone, IRC_ENABLE_INTERRUPT, irq);
     158//      async_hangup(irc_phone);
     159
     160        ret = register_interrupt_handler(device, irq, irq_handler, &uhci_code);
    112161        usb_log_debug("Registered interrupt handler %d.\n", ret);
    113162
Note: See TracChangeset for help on using the changeset viewer.