Changes in uspace/drv/uhci-hcd/main.c [e0df6c2:7e7f0f5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/main.c
re0df6c2 r7e7f0f5 34 34 #include <driver.h> 35 35 #include <usb_iface.h> 36 #include <ipc/irc.h> 37 #include <ipc/ns.h> 38 #include <ipc/services.h> 39 #include <sysinfo.h> 36 40 37 41 #include <errno.h> … … 46 50 #define NAME "uhci-hcd" 47 51 52 static int uhci_add_device(device_t *device); 53 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle); 54 /*----------------------------------------------------------------------------*/ 48 55 static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle) 49 56 { … … 54 61 return EOK; 55 62 } 56 63 /*----------------------------------------------------------------------------*/ 57 64 static usb_iface_t hc_usb_iface = { 58 65 .get_hc_handle = usb_iface_get_hc_handle 59 66 }; 60 67 /*----------------------------------------------------------------------------*/ 61 68 static device_ops_t uhci_ops = { 62 69 .interfaces[USB_DEV_IFACE] = &hc_usb_iface, 63 70 .interfaces[USBHC_DEV_IFACE] = &uhci_iface 64 71 }; 65 72 /*----------------------------------------------------------------------------*/ 73 static driver_ops_t uhci_driver_ops = { 74 .add_device = uhci_add_device, 75 }; 76 /*----------------------------------------------------------------------------*/ 77 static driver_t uhci_driver = { 78 .name = NAME, 79 .driver_ops = &uhci_driver_ops 80 }; 81 /*----------------------------------------------------------------------------*/ 82 static 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 /*----------------------------------------------------------------------------*/ 98 static irq_code_t uhci_code = { 99 sizeof(uhci_cmds) / sizeof(irq_cmd_t), 100 uhci_cmds 101 }; 102 /*----------------------------------------------------------------------------*/ 103 static void irq_handler(device_t *device, ipc_callid_t iid, ipc_call_t *call) 104 { 105 assert(device); 106 uhci_t *hc = dev_to_uhci(device); 107 usb_log_info("LOL HARDWARE INTERRUPT: %p.\n", hc); 108 uint16_t status = IPC_GET_ARG1(*call); 109 assert(hc); 110 uhci_interrupt(hc, status); 111 } 112 /*----------------------------------------------------------------------------*/ 66 113 static int uhci_add_device(device_t *device) 67 114 { … … 75 122 int irq; 76 123 77 int rc = pci_get_my_registers(device, 78 &io_reg_base, &io_reg_size, &irq); 79 80 if (rc != EOK) { 81 usb_log_error("Failed(%d) to get I/O registers addresses for device:.\n", 82 rc, device->handle); 83 return rc; 124 int ret = 125 pci_get_my_registers(device, &io_reg_base, &io_reg_size, &irq); 126 127 if (ret != EOK) { 128 usb_log_error( 129 "Failed(%d) to get I/O registers addresses for device:.\n", 130 ret, device->handle); 131 return ret; 84 132 } 85 133 … … 87 135 io_reg_base, io_reg_size, irq); 88 136 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); 161 usb_log_debug("Registered interrupt handler %d.\n", ret); 162 89 163 uhci_t *uhci_hc = malloc(sizeof(uhci_t)); 90 164 if (!uhci_hc) { 91 usb_log_error("Failed to alloca ete memory for uhci hcd driver.\n");165 usb_log_error("Failed to allocate memory for uhci hcd driver.\n"); 92 166 return ENOMEM; 93 167 } 94 168 95 intret = uhci_init(uhci_hc, (void*)io_reg_base, io_reg_size);169 ret = uhci_init(uhci_hc, (void*)io_reg_base, io_reg_size); 96 170 if (ret != EOK) { 97 171 usb_log_error("Failed to init uhci-hcd.\n"); … … 100 174 device_t *rh; 101 175 ret = setup_root_hub(&rh, device); 102 103 176 if (ret != EOK) { 104 177 usb_log_error("Failed to setup uhci root hub.\n"); … … 118 191 return EOK; 119 192 } 120 121 static driver_ops_t uhci_driver_ops = { 122 .add_device = uhci_add_device, 123 }; 124 125 static driver_t uhci_driver = { 126 .name = NAME, 127 .driver_ops = &uhci_driver_ops 128 }; 129 193 /*----------------------------------------------------------------------------*/ 130 194 int main(int argc, char *argv[]) 131 195 { 132 /* 133 * Do some global initializations. 134 */ 135 sleep(5); 136 usb_log_enable(USB_LOG_LEVEL_INFO, NAME); 196 sleep(3); 197 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 137 198 138 199 return driver_main(&uhci_driver);
Note:
See TracChangeset
for help on using the changeset viewer.