21 log(
mod,
"Controller reset complete");
43 sizeof(
struct xhci_trb) * 64, &cmd_ring_paddr);
56 sizeof(
struct xhci_trb) * 64, &event_ring_paddr);
59 erst[0].ba = (
uint64_t) event_ring_paddr;
65 (
uint64_t) event_ring_paddr | (1 << 3);
79 log(
mod,
"Controller started");
92 log(
mod,
"Port %d: Connected (Speed %d)", i + 1, speed);
95 log(
mod,
"Port %d: Resetting...", i + 1);
105 log(
mod,
"Port %d: Slot %d enabled", i + 1,
133 for (
int timeout = 0; timeout < 1000; timeout++) {
135 uint8_t pcs =
event.control & 1;
138 uint8_t ev_type = (
event.control >> 10) & 0x3F;
165 return (ev.
control >> 24) & 0xFF;
175 slots[slot_id].ctx = dev_ctx;
176 slots[slot_id].ctx_phys = ctx_paddr;
177 slots[slot_id].port_id = port_id;
178 slots[slot_id].active =
true;
188 dev_ctx->
ep[0].
info2 = (4 << 3) | (3 << 1);
194 slots[slot_id].rings_phys[0] = ring_paddr;
195 slots[slot_id].ring_indices[0] = 0;
196 slots[slot_id].ring_pcs[0] = 1;
205 IOUtils::memcpy(&input_ctx->
device, dev_ctx,
217 sizeof(
struct xhci_trb) * 64, phys);
225 size_t response_size) {
228 if (!
slots[slot_id].active)
243 if (response_phys && response_size > 0)
256 if (response_phys && response_size > 0) {
258 ring[
idx].status = response_size;
280 slots[slot_id].ring_indices[ep_idx] =
idx;
void address_device(uint8_t slot_id, uint8_t port_id)
struct xhci_trb * create_transfer_ring(uintptr_t *phys)
struct xhci_trb * cmd_ring
volatile uint32_t * doorbell_regs
struct xhci_trb * event_ring
void send_async_with_response(uint8_t addr, uint8_t endpoint, uint32_t data_phys, size_t size, uint32_t response_phys, size_t response_size)
struct XHCIModule::xhci_slot slots[256]
void send_command(struct xhci_trb *trb)
struct xhci_op_regs * op_regs
struct xhci_trb wait_for_event(uint8_t type)
uint32_t event_ring_index
struct xhci_cap_regs * cap_regs
uintptr_t event_ring_phys
struct xhci_runtime_regs * runtime_regs
#define log(mod, fmt,...)
struct xhci_slot_ctx slot
struct xhci_endpoint_ctx ep[31]
#define XHCI_TRB_STATUS_STAGE
#define XHCI_TRB_ADDRESS_DEVICE_CMD
#define XHCI_TRB_ENABLE_SLOT_CMD
#define XHCI_TRB_TRANSFER_EVENT
#define XHCI_TRB_DATA_STAGE
#define XHCI_TRB_COMMAND_COMPLETION_EVENT
#define XHCI_TRB_SETUP_STAGE