mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 15:26:47 +00:00
bugfix: cid错误
This commit is contained in:
parent
63de30bbe0
commit
10537cd1bc
@ -66,7 +66,7 @@ static int xhci_hc_find_available_id()
|
|||||||
|
|
||||||
for (int i = 0; i < XHCI_MAX_HOST_CONTROLLERS; ++i)
|
for (int i = 0; i < XHCI_MAX_HOST_CONTROLLERS; ++i)
|
||||||
{
|
{
|
||||||
if (xhci_hc[i].pci_dev_hdr = NULL)
|
if (xhci_hc[i].pci_dev_hdr == NULL)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -217,13 +217,19 @@ void xhci_init(struct pci_device_structure_general_device_t *dev_hdr)
|
|||||||
kinfo("Initializing xhci host controller: bus=%#02x, device=%#02x, func=%#02x, VendorID=%#04x, irq_line=%d, irq_pin=%d", dev_hdr->header.bus, dev_hdr->header.device, dev_hdr->header.func, dev_hdr->header.Vendor_ID, dev_hdr->Interrupt_Line, dev_hdr->Interrupt_PIN);
|
kinfo("Initializing xhci host controller: bus=%#02x, device=%#02x, func=%#02x, VendorID=%#04x, irq_line=%d, irq_pin=%d", dev_hdr->header.bus, dev_hdr->header.device, dev_hdr->header.func, dev_hdr->header.Vendor_ID, dev_hdr->Interrupt_Line, dev_hdr->Interrupt_PIN);
|
||||||
|
|
||||||
int cid = xhci_hc_find_available_id();
|
int cid = xhci_hc_find_available_id();
|
||||||
|
if (cid < 0)
|
||||||
|
{
|
||||||
|
kerror("Initialize xhci controller failed: exceed the limit of max controllers.");
|
||||||
|
goto failed_exceed_max;
|
||||||
|
}
|
||||||
|
|
||||||
memset(&xhci_hc[cid], 0, sizeof(struct xhci_host_controller_t));
|
memset(&xhci_hc[cid], 0, sizeof(struct xhci_host_controller_t));
|
||||||
xhci_hc[cid].controller_id = cid;
|
xhci_hc[cid].controller_id = cid;
|
||||||
xhci_hc[cid].pci_dev_hdr = dev_hdr;
|
xhci_hc[cid].pci_dev_hdr = dev_hdr;
|
||||||
pci_write_config(dev_hdr->header.bus, dev_hdr->header.device, dev_hdr->header.func, 0x4, 0x0006); // mem I/O access enable and bus master enable
|
pci_write_config(dev_hdr->header.bus, dev_hdr->header.device, dev_hdr->header.func, 0x4, 0x0006); // mem I/O access enable and bus master enable
|
||||||
|
|
||||||
// 为当前控制器映射寄存器地址空间
|
// 为当前控制器映射寄存器地址空间
|
||||||
xhci_hc[cid].vbase = SPECIAL_MEMOEY_MAPPING_VIRT_ADDR_BASE + XHCI_MAPPING_OFFSET + PAGE_2M_SIZE * xhci_hc[cid].controller_id;
|
xhci_hc[cid].vbase = SPECIAL_MEMOEY_MAPPING_VIRT_ADDR_BASE + XHCI_MAPPING_OFFSET + 65536 * xhci_hc[cid].controller_id;
|
||||||
kdebug("dev_hdr->BAR0 & (~0xf)=%#018lx", dev_hdr->BAR0 & (~0xf));
|
kdebug("dev_hdr->BAR0 & (~0xf)=%#018lx", dev_hdr->BAR0 & (~0xf));
|
||||||
mm_map_phys_addr(xhci_hc[cid].vbase, dev_hdr->BAR0 & (~0xf), 65536, PAGE_KERNEL_PAGE | PAGE_PWT | PAGE_PCD, true);
|
mm_map_phys_addr(xhci_hc[cid].vbase, dev_hdr->BAR0 & (~0xf), 65536, PAGE_KERNEL_PAGE | PAGE_PWT | PAGE_PCD, true);
|
||||||
|
|
||||||
@ -269,6 +275,7 @@ failed:;
|
|||||||
|
|
||||||
// 清空数组
|
// 清空数组
|
||||||
memset((void *)&xhci_hc[cid], 0, sizeof(struct xhci_host_controller_t));
|
memset((void *)&xhci_hc[cid], 0, sizeof(struct xhci_host_controller_t));
|
||||||
|
failed_exceed_max:;
|
||||||
kerror("Failed to initialize controller: bus=%d, dev=%d, func=%d", dev_hdr->header.bus, dev_hdr->header.device, dev_hdr->header.func);
|
kerror("Failed to initialize controller: bus=%d, dev=%d, func=%d", dev_hdr->header.bus, dev_hdr->header.device, dev_hdr->header.func);
|
||||||
spin_unlock(&xhci_controller_init_lock);
|
spin_unlock(&xhci_controller_init_lock);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user