XHCI test sending noop command
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 3m12s
Build documentation / build-and-deploy (push) Successful in 3m13s

This commit is contained in:
2026-03-22 23:09:21 +01:00
parent 5cdeb87393
commit b35fc5545c
11 changed files with 360 additions and 31 deletions

View File

@@ -1,3 +1,5 @@
#include <amd64/apic.h>
#include <amd64/intr_defs.h>
#include <device/def_device_op.h>
#include <device/device.h>
#include <device/pci.h>
@@ -28,7 +30,7 @@ bool pci_xhci_init (struct proc* proc, struct reschedule_ctx* rctx, struct pci_i
uint16_t pci_cmd = pci_read16 (pci_info.bus, pci_info.slot, pci_info.func, PCI_COMMAND);
uint16_t new_cmd = (pci_cmd | (1 << 1) | (1 << 2));
uint16_t new_cmd = (pci_cmd | (1 << 1) | (1 << 2)) & ~(1 << 10);
if (pci_cmd != new_cmd) {
pci_write16 (pci_info.bus, pci_info.slot, pci_info.func, PCI_COMMAND, new_cmd);
@@ -55,13 +57,35 @@ bool pci_xhci_init (struct proc* proc, struct reschedule_ctx* rctx, struct pci_i
uintptr_t xhci_base = xhci_phys + (uintptr_t)hhdm->offset;
/* 2 pages should cover the mmio space */
mm_map_kernel_page (xhci_phys, xhci_base, MM_PG_RW | MM_PG_PRESENT);
mm_map_kernel_page (xhci_phys + PAGE_SIZE, xhci_base + PAGE_SIZE, MM_PG_RW | MM_PG_PRESENT);
for (size_t page = 0; page < 8; page++) {
mm_map_kernel_page (xhci_phys + page * PAGE_SIZE, xhci_base + page * PAGE_SIZE,
MM_PG_RW | MM_PG_PRESENT);
}
bool irqs_support = false;
if (!pci_msi_init (pci_info.bus, pci_info.slot, pci_info.func, INTR_XHCI, thiscpu->lapic_id)) {
uint8_t intr_line = pci_read8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_INTERRUPT_LINE);
uint8_t intr_pin = pci_read8 (pci_info.bus, pci_info.slot, pci_info.func, PCI_INTERRUPT_PIN);
if (intr_pin != 0) {
irqs_support = true;
ioapic_route_irq (INTR_XHCI, intr_line, 0, thiscpu->lapic_id);
}
} else {
irqs_support = true;
}
DEBUG ("IRQ support=%d\n", irqs_support);
char key[32];
snprintf (key, sizeof (key), "xhci%d", xhci_counter++);
struct xhci_init init = {.xhci_mmio_base = xhci_base};
struct xhci_init init = {
.xhci_mmio_base = xhci_base,
.irqs_support = irqs_support,
.irq = INTR_XHCI,
};
device_op_func_t ops[] = {0};