setos

拙OS
Log | Files | Refs | LICENSE

commit 66184e97d9c3649e57c666c23e34cbafa9068194
parent b1d20f135d39e92d85d230b821eccbb712f816f5
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Mon,  6 May 2024 15:30:58 +0900

read PORTSC

Diffstat:
Msys/include/xhc.h | 8+++++++-
Msys/src/kernel/main.c | 10+++++++++-
2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/sys/include/xhc.h b/sys/include/xhc.h @@ -40,7 +40,13 @@ struct xhc_operational_registers { uint8 RsvdZ1[16]; uint64 DCBAAP; uint32 CONFIG; - // TODO: port register set + uint8 RsvdZ2[0x400-0x3c]; + struct PRS { + uint32 PORTSC; + uint32 PORTPMSC; + uint32 PORTLI; + uint32 PORTHLPMC; + } PRS[]; }; struct xhc_runtime_registers { diff --git a/sys/src/kernel/main.c b/sys/src/kernel/main.c @@ -28,7 +28,7 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) root_window.children = root_children; Window win0; - make_window(&root_window, &win0, (Point){150, 100}, (Point){400, 500}, 0xff, 0xb9d08bff); + make_window(&root_window, &win0, (Point){150, 100}, (Point){400, 700}, 0xff, 0xb9d08bff); Console con0 = { .win = &win0, .font = &asciifont, @@ -207,6 +207,14 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) xhc.runtime->IR[0].ERDP = (uint64) ERDP|(xhc.runtime->IR[0].ERDP&0xf); cons_printf(&con0, "processed event ring\n"); + // reset port. + for (;(xhc.op->PRS[0].PORTSC&(1<<17|1)) != (1<<17|1);) { // PORTSC.CSC&PORTSC.CCS + } + cons_printf(&con0, "usb device connected: PORTSC: %x\n", + xhc.op->PRS[0].PORTSC); + cons_printf(&con0, "offset of prs[0]: %x\n", + (uintptr) xhc.op->PRS - (uintptr) xhc.op); + halt: for(;;) { __asm__("hlt"); } }