[Voyageurs] Send AddressDevice Command to move port to 'Addressed' State.
This commit is contained in:
parent
dd2687a59a
commit
8e78950ac7
10 changed files with 236 additions and 33 deletions
|
|
@ -1,26 +1,27 @@
|
|||
#include "xhci/trb.h"
|
||||
|
||||
constexpr uint8_t kTrb_Normal = 1;
|
||||
constexpr uint8_t kTrb_SetupStage = 2;
|
||||
constexpr uint8_t kTrb_DataStage = 3;
|
||||
constexpr uint8_t kTrb_StatusStage = 4;
|
||||
constexpr uint8_t kTrb_Isoch = 5;
|
||||
constexpr uint8_t kTrb_Link = 6;
|
||||
constexpr uint8_t kTrb_EventData = 7;
|
||||
constexpr uint8_t kTrb_NoOp = 8;
|
||||
constexpr uint8_t kTrb_EnableSlot = 9;
|
||||
constexpr uint8_t kTrb_DisableSlot = 10;
|
||||
constexpr uint8_t kTrb_NoOpCommand = 23;
|
||||
|
||||
constexpr uint8_t kTrb_TypeOffset = 10;
|
||||
|
||||
constexpr uint8_t kTrb_Cycle = 1;
|
||||
constexpr uint16_t kTrb_Cycle = 1;
|
||||
constexpr uint16_t kTrb_BSR = (1 << 9);
|
||||
|
||||
namespace {
|
||||
|
||||
uint16_t TypeToInt(TrbType type) {
|
||||
return static_cast<uint16_t>(type) << kTrb_TypeOffset;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TrbType GetType(const XhciTrb& trb) {
|
||||
return TrbType(trb.type_and_cycle >> kTrb_TypeOffset);
|
||||
}
|
||||
|
||||
XhciTrb CreateLinkTrb(uint64_t physical_address) {
|
||||
return {
|
||||
.parameter = physical_address,
|
||||
.status = 0,
|
||||
.type_and_cycle = kTrb_Link << kTrb_TypeOffset,
|
||||
.type_and_cycle = TypeToInt(TrbType::Link),
|
||||
.control = 0,
|
||||
};
|
||||
}
|
||||
|
|
@ -30,18 +31,30 @@ XhciTrb CreateEnableSlotTrb() {
|
|||
.parameter = 0,
|
||||
.status = 0,
|
||||
// FIXME: Accept Cycle Bit as a parameter.
|
||||
.type_and_cycle = kTrb_EnableSlot << kTrb_TypeOffset | kTrb_Cycle,
|
||||
.type_and_cycle = (uint16_t)(TypeToInt(TrbType::EnableSlot) | kTrb_Cycle),
|
||||
// FIXME: Specify slot type if necessary. (XHCI Table 7-9)?
|
||||
.control = 0,
|
||||
};
|
||||
}
|
||||
|
||||
XhciTrb CreateAddressDeviceCommand(uint64_t input_context, uint8_t slot_id) {
|
||||
return {
|
||||
.parameter = input_context,
|
||||
.status = 0,
|
||||
// Always cycle the device straight to addressed.
|
||||
.type_and_cycle =
|
||||
(uint16_t)(TypeToInt(TrbType::AddressDevice) | kTrb_Cycle),
|
||||
.control = (uint16_t)(slot_id << 8),
|
||||
};
|
||||
}
|
||||
|
||||
XhciTrb CreateNoOpCommandTrb() {
|
||||
return {
|
||||
.parameter = 0,
|
||||
.status = 0,
|
||||
// FIXME: Accept Cycle Bit as a parameter.
|
||||
.type_and_cycle = kTrb_NoOpCommand << kTrb_TypeOffset | kTrb_Cycle,
|
||||
.type_and_cycle =
|
||||
(uint16_t)(TypeToInt(TrbType::NoOpCommand) | kTrb_Cycle),
|
||||
.control = 0,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue