setos

拙OS
Log | Files | Refs | LICENSE

commit d1c677c4eac29920b32eff802a6bbad88dc50634
parent c37dd9abcc01fb7ebbb665d7d689dd164a079199
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Mon,  6 May 2024 14:01:06 +0900

process event ring

Diffstat:
Msys/src/kernel/main.c | 17++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/sys/src/kernel/main.c b/sys/src/kernel/main.c @@ -111,6 +111,7 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) // setup the command ring. xhc_trb command_ring[16] __attribute__((aligned(64))) = {0}; + int command_ring_pcs = 1; // set link TRB. command_ring[15].parameter = (uint64) command_ring; command_ring[15].control = 6 << 10; // TRB type: link TRB @@ -119,6 +120,7 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) // setup an event ring. xhc_trb event_ring_segment_table[1] __attribute__((aligned(64))) = {0}; xhc_trb event_ring_segment[16] __attribute__((aligned(16))) = {0}; + int event_ring_ccs = 1; event_ring_segment_table[0].parameter = (uint64) event_ring_segment; event_ring_segment_table[0].status = 16; xhc.runtime->IR[0].ERSTSZ = sizeof(event_ring_segment_table) / sizeof(event_ring_segment_table[0]); @@ -189,11 +191,20 @@ kernel_main(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) cons_printf(&con0, "xHC started\n"); // read ERDP - int trb_ccs = 0; xhc_trb *ERDP = (xhc_trb *) (xhc.runtime->IR[0].ERDP&~0xf); cons_printf(&con0, "ERDP: %x\n", ERDP); - cons_printf(&con0, "parameter:\t%x\nstatus:\t%x\ncontrol:\t%x\n", - ERDP->parameter, ERDP->status, ERDP->control); + cons_printf(&con0, "event_ring_segment: %x\n", event_ring_segment); + for (; (ERDP->control&0x1) == event_ring_ccs; ERDP += sizeof(xhc_trb)) { + if (ERDP >= event_ring_segment + + sizeof(xhc_trb)*event_ring_segment_table[0].status) { + ERDP = event_ring_segment; + event_ring_ccs = !event_ring_ccs; + } + ERDP->control = (ERDP->control&0xfffffffe) | !event_ring_ccs; + cons_printf(&con0, "parameter:\t%x\nstatus:\t%x\ncontrol:\t%x\n", + ERDP->parameter, ERDP->status, ERDP->control); + } + cons_printf(&con0, "processed event ring\n"); halt: for(;;) { __asm__("hlt"); }