From e6b232851e16590c3d79cc411c431fa0bb0723ff Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Sat, 24 Feb 2024 14:23:14 -0800 Subject: [PATCH] [Voyageurs] Add 10 trbs to the queue to handle rapid keypresses. --- sys/voyageurs/xhci/endpoint.cpp | 22 ++++++++++++++-------- sys/voyageurs/xhci/endpoint.h | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/sys/voyageurs/xhci/endpoint.cpp b/sys/voyageurs/xhci/endpoint.cpp index a1149f0..b08d6ed 100644 --- a/sys/voyageurs/xhci/endpoint.cpp +++ b/sys/voyageurs/xhci/endpoint.cpp @@ -12,20 +12,26 @@ void Endpoint::Initialize(XhciEndpointContext* context) { context_->tr_dequeue_ptr = trb_ring_->PhysicalAddress() | 1; context_->error_and_type = (0x3 << 1) | (0x7 << 3) | (0x8 << 16); - trb_ring_->EnqueueTrb({ - .parameter = recv_phys_, - .status = 8, - .type_and_cycle = 1 | (1 << 2) | (1 << 5) | (1 << 10), - .control = 0, - }); + for (uint64_t i = 0; i < 10; i++) { + trb_ring_->EnqueueTrb({ + .parameter = recv_phys_ + offset_, + .status = 8, + .type_and_cycle = 1 | (1 << 2) | (1 << 5) | (1 << 10), + .control = 0, + }); + offset_ += 8; + } } void Endpoint::TransferComplete(uint64_t trb_phys) { - dbgln("Data: {x}", *(uint64_t*)recv_mem_.vaddr()); + uint64_t phys_offset = + (trb_phys - trb_ring_->PhysicalAddress()) / sizeof(XhciTrb); + dbgln("Data: {x}", *((uint64_t*)recv_mem_.vaddr() + phys_offset)); trb_ring_->EnqueueTrb({ - .parameter = recv_phys_, + .parameter = recv_phys_ + offset_, .status = 8, .type_and_cycle = 1 | (1 << 2) | (1 << 5) | (1 << 10), .control = 0, }); + offset_ += 8; } diff --git a/sys/voyageurs/xhci/endpoint.h b/sys/voyageurs/xhci/endpoint.h index 25b0a45..920620a 100644 --- a/sys/voyageurs/xhci/endpoint.h +++ b/sys/voyageurs/xhci/endpoint.h @@ -23,4 +23,5 @@ class Endpoint { uint64_t recv_phys_; mmth::OwnedMemoryRegion recv_mem_; + uint64_t offset_ = 0; };