[Voyageurs] Create an abstraction for managing TRBs.
This commit is contained in:
parent
2228b5b52e
commit
b41784b938
8 changed files with 78 additions and 40 deletions
24
sys/voyageurs/xhci/trb_ring.cpp
Normal file
24
sys/voyageurs/xhci/trb_ring.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "xhci/trb_ring.h"
|
||||
|
||||
#include <mammoth/util/debug.h>
|
||||
|
||||
#include "xhci/trb.h"
|
||||
|
||||
TrbRing::TrbRing() {
|
||||
uint64_t number_trbs = 0x1000 / sizeof(XhciTrb);
|
||||
page_ = mmth::OwnedMemoryRegion::ContiguousPhysical(0x1000, &phys_address_);
|
||||
trb_list_ = glcr::ArrayView<XhciTrb>(
|
||||
reinterpret_cast<XhciTrb*>(page_.vaddr()), number_trbs);
|
||||
|
||||
// Point the end of the command ring back to the start.
|
||||
trb_list_[trb_list_.size() - 1] = CreateLinkTrb(phys_address_);
|
||||
}
|
||||
|
||||
void TrbRingWriter::EnqueueTrb(const XhciTrb& trb) {
|
||||
uint64_t ptr = enqueue_ptr_++;
|
||||
if (enqueue_ptr_ == trb_list_.size()) {
|
||||
crash("Not implemented: queue wrapping", glcr::UNIMPLEMENTED);
|
||||
}
|
||||
|
||||
trb_list_[ptr] = trb;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue