[Voyageurs] Move NormalTrb generation into helper func.
This commit is contained in:
parent
e6b232851e
commit
3c1e435e04
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include <mammoth/util/debug.h>
|
#include <mammoth/util/debug.h>
|
||||||
|
|
||||||
|
#include "xhci/trb.h"
|
||||||
|
|
||||||
void Endpoint::Initialize(XhciEndpointContext* context) {
|
void Endpoint::Initialize(XhciEndpointContext* context) {
|
||||||
enabled_ = true;
|
enabled_ = true;
|
||||||
context_ = context;
|
context_ = context;
|
||||||
|
@ -13,12 +15,7 @@ void Endpoint::Initialize(XhciEndpointContext* context) {
|
||||||
|
|
||||||
context_->error_and_type = (0x3 << 1) | (0x7 << 3) | (0x8 << 16);
|
context_->error_and_type = (0x3 << 1) | (0x7 << 3) | (0x8 << 16);
|
||||||
for (uint64_t i = 0; i < 10; i++) {
|
for (uint64_t i = 0; i < 10; i++) {
|
||||||
trb_ring_->EnqueueTrb({
|
trb_ring_->EnqueueTrb(CreateNormalTrb(recv_phys_ + offset_, 8));
|
||||||
.parameter = recv_phys_ + offset_,
|
|
||||||
.status = 8,
|
|
||||||
.type_and_cycle = 1 | (1 << 2) | (1 << 5) | (1 << 10),
|
|
||||||
.control = 0,
|
|
||||||
});
|
|
||||||
offset_ += 8;
|
offset_ += 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +24,6 @@ void Endpoint::TransferComplete(uint64_t trb_phys) {
|
||||||
uint64_t phys_offset =
|
uint64_t phys_offset =
|
||||||
(trb_phys - trb_ring_->PhysicalAddress()) / sizeof(XhciTrb);
|
(trb_phys - trb_ring_->PhysicalAddress()) / sizeof(XhciTrb);
|
||||||
dbgln("Data: {x}", *((uint64_t*)recv_mem_.vaddr() + phys_offset));
|
dbgln("Data: {x}", *((uint64_t*)recv_mem_.vaddr() + phys_offset));
|
||||||
trb_ring_->EnqueueTrb({
|
trb_ring_->EnqueueTrb(CreateNormalTrb(recv_phys_ + offset_, 8));
|
||||||
.parameter = recv_phys_ + offset_,
|
|
||||||
.status = 8,
|
|
||||||
.type_and_cycle = 1 | (1 << 2) | (1 << 5) | (1 << 10),
|
|
||||||
.control = 0,
|
|
||||||
});
|
|
||||||
offset_ += 8;
|
offset_ += 8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ constexpr uint8_t kTrb_TypeOffset = 10;
|
||||||
|
|
||||||
constexpr uint16_t kTrb_Cycle = 1;
|
constexpr uint16_t kTrb_Cycle = 1;
|
||||||
constexpr uint16_t kTrb_ToggleCycle = (1 << 1);
|
constexpr uint16_t kTrb_ToggleCycle = (1 << 1);
|
||||||
|
constexpr uint16_t kTrb_InterruptShortPacket = (1 << 2);
|
||||||
|
constexpr uint16_t kTrb_Interrupt = (1 << 5);
|
||||||
constexpr uint16_t kTrb_BSR = (1 << 9);
|
constexpr uint16_t kTrb_BSR = (1 << 9);
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -18,6 +20,16 @@ TrbType GetType(const XhciTrb& trb) {
|
||||||
return TrbType(trb.type_and_cycle >> kTrb_TypeOffset);
|
return TrbType(trb.type_and_cycle >> kTrb_TypeOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XhciTrb CreateNormalTrb(uint64_t physical_address, uint8_t size) {
|
||||||
|
return {
|
||||||
|
.parameter = physical_address,
|
||||||
|
.status = size,
|
||||||
|
.type_and_cycle = (uint16_t)(TypeToInt(TrbType::Normal) | kTrb_Cycle |
|
||||||
|
kTrb_Interrupt | kTrb_InterruptShortPacket),
|
||||||
|
.control = 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
XhciTrb CreateLinkTrb(uint64_t physical_address) {
|
XhciTrb CreateLinkTrb(uint64_t physical_address) {
|
||||||
return {
|
return {
|
||||||
.parameter = physical_address,
|
.parameter = physical_address,
|
||||||
|
|
|
@ -29,6 +29,7 @@ enum class TrbType : uint8_t {
|
||||||
|
|
||||||
TrbType GetType(const XhciTrb& trb);
|
TrbType GetType(const XhciTrb& trb);
|
||||||
|
|
||||||
|
XhciTrb CreateNormalTrb(uint64_t physical_address, uint8_t size);
|
||||||
XhciTrb CreateLinkTrb(uint64_t physical_address);
|
XhciTrb CreateLinkTrb(uint64_t physical_address);
|
||||||
|
|
||||||
XhciTrb CreateEnableSlotTrb();
|
XhciTrb CreateEnableSlotTrb();
|
||||||
|
|
Loading…
Reference in New Issue