xhci.c 963 B

12345678910111213141516171819202122232425262728
  1. #include "xhci.h"
  2. #include <common/kprint.h>
  3. #include <debug/bug.h>
  4. #include <process/spinlock.h>
  5. spinlock_t xhci_controller_init_lock; // xhci控制器初始化锁(在usb_init中被初始化)
  6. static int xhci_ctrl_count = 0; // xhci控制器计数
  7. /**
  8. * @brief 初始化xhci控制器
  9. *
  10. * @param header 指定控制器的pci device头部
  11. */
  12. void xhci_init(struct pci_device_structure_general_device_t *dev_hdr)
  13. {
  14. spin_lock(&xhci_controller_init_lock);
  15. 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 );
  16. 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
  17. ++xhci_ctrl_count;
  18. spin_unlock(&xhci_controller_init_lock);
  19. }