[Voyageurs] XHCI Event Segment working with polling.

This commit is contained in:
Drew Galbraith 2024-02-22 13:25:49 -08:00
parent b41784b938
commit 4cb0b0b2ae
8 changed files with 181 additions and 21 deletions

View file

@ -7,6 +7,12 @@
TrbRing::TrbRing() {
uint64_t number_trbs = 0x1000 / sizeof(XhciTrb);
page_ = mmth::OwnedMemoryRegion::ContiguousPhysical(0x1000, &phys_address_);
// Zero out data.
uint64_t* page_ptr = reinterpret_cast<uint64_t*>(page_.vaddr());
for (uint64_t i = 0; i < 0x1000 / sizeof(uint64_t); i++) {
page_ptr[i] = 0;
}
trb_list_ = glcr::ArrayView<XhciTrb>(
reinterpret_cast<XhciTrb*>(page_.vaddr()), number_trbs);
@ -22,3 +28,9 @@ void TrbRingWriter::EnqueueTrb(const XhciTrb& trb) {
trb_list_[ptr] = trb;
}
bool TrbRingReader::HasNext() {
return (trb_list_[dequeue_ptr_].type_and_cycle & 0x1) == cycle_bit_;
}
XhciTrb TrbRingReader::Read() { return trb_list_[dequeue_ptr_++]; }