diff --git a/system/ohci.c b/system/ohci.c index e9fe5de..beaacd5 100644 --- a/system/ohci.c +++ b/system/ohci.c @@ -21,7 +21,7 @@ // Values defined by the OHCI specification. -// HcRevision register +// HcControl register #define OHCI_CTRL_CBSR 0x00000003 // Control Bulk Service Ratio #define OHCI_CTRL_CBSR0 0x00000000 // Control Bulk Service Ratio 0 @@ -592,7 +592,7 @@ bool ohci_init(uintptr_t base_addr, usb_hcd_t *hcd) // Initialise the interrupt ED and TD for each keyboard interface and find the minimum interval. int min_interval = OHCI_MAX_INTERVAL; - ohci_ed_t *last_kbd_ed = NULL; + uint32_t intr_head_ed = 0; for (int kbd_idx = 0; kbd_idx < num_keyboards; kbd_idx++) { usb_ep_t *kbd = &keyboards[kbd_idx]; @@ -604,8 +604,8 @@ bool ohci_init(uintptr_t base_addr, usb_hcd_t *hcd) build_ohci_td(kbd_td, OHCI_TD_DP_IN | OHCI_TD_DT_USE_TD | OHCI_TD_DT_0 | OHCI_TD_DI_NO_DLY, kbd_rpt, sizeof(hid_kbd_rpt_t)); build_ohci_ed(kbd_ed, ohci_ed_control(kbd), kbd_td+0, kbd_td+1); - kbd_ed->next_ed = (uintptr_t)last_kbd_ed; - last_kbd_ed = kbd_ed; + kbd_ed->next_ed = intr_head_ed; + intr_head_ed = (uintptr_t)kbd_ed; if (kbd->interval < min_interval) { min_interval = kbd->interval; @@ -614,7 +614,7 @@ bool ohci_init(uintptr_t base_addr, usb_hcd_t *hcd) // Initialise the interrupt table. for (int i = 0; i < OHCI_MAX_INTERVAL; i += min_interval) { - ws->hcca.intr_head_ed[i] = (uintptr_t)last_kbd_ed; + ws->hcca.intr_head_ed[i] = intr_head_ed; } write32(&op_regs->control, OHCI_CTRL_HCFS_RUN | OHCI_CTRL_CLE | OHCI_CTRL_PLE | OHCI_CTRL_CBSR0); flush32(&op_regs->interrupt_status, ~0); diff --git a/system/xhci.c b/system/xhci.c index 972f9d2..8991d3f 100644 --- a/system/xhci.c +++ b/system/xhci.c @@ -102,8 +102,7 @@ // Add Context flags -#define XHCI_CONTEXT_A0 (1 << 0) -#define XHCI_CONTEXT_A1 (1 << 1) +#define XHCI_CONTEXT_A(n) (1 << (n)) // Port Speed values @@ -737,7 +736,7 @@ static bool assign_address(const usb_hcd_t *hcd, const usb_hub_t *hub, int port_ // Prepare the input context for the ADDRESS_DEVICE command. xhci_ctrl_context_t *ctrl_context = (xhci_ctrl_context_t *)ws->input_context_addr; - ctrl_context->add_context_flags = XHCI_CONTEXT_A0 | XHCI_CONTEXT_A1; + ctrl_context->add_context_flags = XHCI_CONTEXT_A(0) | XHCI_CONTEXT_A(1); xhci_slot_context_t *slot_context = (xhci_slot_context_t *)(ws->input_context_addr + ws->context_size); slot_context->params1 = 1 << 27 | usb_to_xhci_speed(device_speed) << 20; @@ -828,7 +827,7 @@ static bool configure_interrupt_endpoint(workspace_t *ws, const usb_ep_t *ep, in // CONFIGURE_ENDPOINT command before issuing the command. xhci_ctrl_context_t *ctrl_context = (xhci_ctrl_context_t *)ws->input_context_addr; - ctrl_context->add_context_flags = XHCI_CONTEXT_A0 | 1 << ep_id; + ctrl_context->add_context_flags = XHCI_CONTEXT_A(0) | XHCI_CONTEXT_A(ep_id); xhci_slot_context_t *slot_context = (xhci_slot_context_t *)(ws->input_context_addr + ws->context_size); slot_context->params1 = ep_id << 27 | hub_flag << 26 | (slot_context->params1 & 0x00ffffff);