commit 1885b0a320d874cdf71d9b55545ca59b8aaa031c
parent f1f3b60694fd69a957072dc161ded0fc1b993997
Author: Matsuda Kenji <info@mtkn.jp>
Date: Tue, 21 May 2024 08:02:43 +0900
reset port
Diffstat:
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/sys/src/kernel/main.c b/sys/src/kernel/main.c
@@ -209,14 +209,28 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
// reset port.
int max_ports = xhc.cap->HCSPARAMS1>>24;
+ struct PRS *port = NULL;
cons_printf(&con0, "MaxPorts: %x\n", max_ports);
for (int i = 0; i < max_ports; i++) {
if ((xhc.op->PRS[i].PORTSC&(1<<17|1)) == (1<<17|1)) { // PORTSC.CSC&PORTSC.CCS
cons_printf(&con0, "%d:\tPORTSC: %x\n",
i, xhc.op->PRS[i].PORTSC);
-
+ port = &xhc.op->PRS[i];
}
}
+ if (port == NULL) {
+ cons_printf(&con0, "no port enabled.\n");
+ goto halt;
+ }
+ uint32 st = port->PORTSC;
+ st ^= 1<<31|1<<29|1<<28|1<<23|1<<22|1<<21|1<<20|1<<19|1<<18|1<<2|1<<1;
+ port->PORTSC = st|1<<17|1<<4; // PORTSC.CSC&PORTSC.PR
+ for (;(port->PORTSC&(1<<4)) != 0;) { // wait for PORTSC.PR becomes 0.
+ }
+ cons_printf(&con0, "port:\tPORTSC: %x\n", port->PORTSC);
+
+ // assign a slot.
+
cons_printf(&con0, "offset of prs[0]: %x\n",
(uintptr) xhc.op->PRS - (uintptr) xhc.op);