commit c3a52cac8ea2b8ad646eea78ba059b54bd2f7c34
parent d81db8cae5a76791fc0ce05ea92db74b96522e8e
Author: Matsuda Kenji <info@mtkn.jp>
Date: Mon, 6 May 2024 09:19:57 +0900
use nec-usb-xhci to use MSI
Diffstat:
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/sys/src/Makefile b/sys/src/Makefile
@@ -78,7 +78,7 @@ run: disk.img OVMF.fd
qemu-system-x86_64 \
-bios OVMF.fd \
-drive format=raw,file=disk.img \
- -device qemu-xhci,id=xhci \
+ -device nec-usb-xhci,id=xhci \
-device usb-mouse,bus=xhci.0
gdb: disk.img OVMF.fd
diff --git a/sys/src/kernel/main.c b/sys/src/kernel/main.c
@@ -79,8 +79,9 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
// reset xhc.
if ((xhc.op->USBSTS & 0x1) != 1) { // USBSTS.HCH
- cons_printf(&con0, "USBSTS.HCH != 1\n");
- goto halt;
+ xhc.op->USBCMD &= ~0x1; // stop xhc.
+ for (;(xhc.op->USBSTS & 0x1) != 1;) {
+ }
}
xhc.op->USBCMD |= 1 << 1; // USBCMD.HCRST
for (;(xhc.op->USBCMD&(1<<1)) != 0;) {
@@ -138,8 +139,9 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
cons_printf(&con0, "MSI\n");
break;
case 0x11:
- MSIXCap *msix_cap = (MSIXCap *)cap;
cons_printf(&con0, "MSI-X\n");
+ /* pending development
+ MSIXCap *msix_cap = (MSIXCap *)cap;
// enable msi-x
msix_cap->message_control |= 1 << 15;
cons_printf(&con0, "message control: %x\n", msix_cap->message_control);
@@ -147,7 +149,13 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
uintptr bar = ((uintptr) pci_xhc->t0.base_address_register[bir+1]) << 32 |
(pci_xhc->t0.base_address_register[bir]&0xfffffff0);
MSIXTab msixtab = (MSIXTab)(bar + (msix_cap->table_offset&~0x3));
-
+ // setup message
+ uint32 msix_msg __attribute__((aligned(32)));
+ cons_printf(&con0, "&msix_msg: %x\n", &msix_msg);
+ msixtab[0].MsgAddr = (uint32) ((uint64)&msix_msg)&0xffffffff;
+ msixtab[0].MsgUpperAddr = (uint32) (((uint64)&msix_msg)>>32)&0xffffffff;
+ msixtab[0].MsgData = 0xdeadbeef;
+ msixtab[0].VectorControl &= ~0x1;
cons_printf(&con0, "capability_id: %x\n", msix_cap->capability_id);
cons_printf(&con0, "next_pointer: %x\n", msix_cap->next_pointer);
cons_printf(&con0, "table_offset: %x\n", msix_cap->table_offset);
@@ -155,6 +163,7 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
cons_printf(&con0, "msgaddr:\t%x\nmsgupperaddr:\t%x\nmsgdata:\t%x\nvectorcontrol:\t%x\n",
msixtab[0].MsgAddr, msixtab[0].MsgUpperAddr,
msixtab[0].MsgData, msixtab[0].VectorControl);
+ */
break;
default:
cons_printf(&con0, "unsupported capability: 0x%x\n",