Artemis Milestone 2e (in progress): xHCI Command Ring write path proven live
Enable Slot command TRB submitted via a new xhci_submit_command()/ xhci_cmd_enable_slot(), ring doorbell 0, confirmed by a real Command Completion Event on all three architectures -- the first time this driver has written a TRB rather than only reading the Event Ring (2d). Added the Command Ring's previously-missing Link TRB (xHCI 1.2 spec sec 4.9.2) for wraparound correctness. Port Register connect/disconnect handling, slot-ID/context bookkeeping, Address Device, and the callback surface into Section U's code are still open -- this is the discriminating first step, not full 2e. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZ8kNoTuP63pbQtro4qvrm
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
2b16daba16
commit
9c8ad8f6ff
@@ -184,12 +184,24 @@ typedef struct {
|
||||
#define XHCI_TRB_TYPE(ctrl) (((ctrl) & XHCI_TRB_CONTROL_TYPE_MASK) >> XHCI_TRB_CONTROL_TYPE_SHIFT)
|
||||
|
||||
/* TRB types used by this driver (subset — xHCI defines many more) */
|
||||
#define XHCI_TRB_TYPE_LINK 6 /* ring-wraparound marker, Command/Transfer Rings only */
|
||||
#define XHCI_TRB_TYPE_ENABLE_SLOT_CMD 9
|
||||
#define XHCI_TRB_TYPE_ADDRESS_DEVICE_CMD 11
|
||||
#define XHCI_TRB_TYPE_TRANSFER_EVENT 32
|
||||
#define XHCI_TRB_TYPE_COMMAND_COMPLETION_EVT 33
|
||||
#define XHCI_TRB_TYPE_PORT_STATUS_CHANGE_EVT 34
|
||||
|
||||
/* Control bits used only by Link TRBs */
|
||||
#define XHCI_TRB_CONTROL_TC (1u << 1) /* Toggle Cycle */
|
||||
|
||||
/* Command Completion Event TRB layout (xHCI 1.2 spec table 6-32):
|
||||
* parameter[63:4] = Command TRB Pointer, status[31:24] = Completion Code,
|
||||
* status[23:0] = unused here, control[31:24] = Slot ID (Enable Slot's
|
||||
* result, also present on Address Device completions). */
|
||||
#define XHCI_EVT_COMPLETION_CODE(status) (((uint32_t)(status) >> 24) & 0xFFu)
|
||||
#define XHCI_EVT_SLOT_ID(control) (((uint32_t)(control) >> 24) & 0xFFu)
|
||||
#define XHCI_COMPLETION_CODE_SUCCESS 1u
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Ring sizing — decided up front per Milestone 2's punch list (2a).
|
||||
*
|
||||
|
||||
@@ -29,8 +29,11 @@ typedef struct {
|
||||
/* Set up by xhci_bringup(); NULL/0 until then. */
|
||||
void *dcbaa; /* Device Context Base Address Array */
|
||||
void *scratchpad_arr; /* array of scratchpad buffer pointers, if any */
|
||||
xhci_trb_t *cmd_ring; /* Command Ring, XHCI_RING_TRB_COUNT TRBs */
|
||||
xhci_trb_t *cmd_ring; /* Command Ring, XHCI_RING_TRB_COUNT TRBs;
|
||||
* index XHCI_RING_TRB_COUNT-1 is a
|
||||
* permanent Link TRB back to index 0 */
|
||||
uint32_t cmd_ring_cycle; /* current Command Ring Cycle State (RCS) */
|
||||
uint32_t cmd_ring_enq; /* next free Command Ring index (0..COUNT-2) */
|
||||
xhci_trb_t *evt_ring; /* Event Ring, XHCI_RING_TRB_COUNT TRBs */
|
||||
void *evt_ring_seg_table; /* Event Ring Segment Table (1 entry) */
|
||||
uint32_t evt_ring_cycle; /* current Event Ring Cycle State */
|
||||
@@ -99,4 +102,17 @@ int xhci_bringup(xhci_dev_t *dev);
|
||||
*/
|
||||
void xhci_poll_events(void);
|
||||
|
||||
/*
|
||||
* xhci_cmd_enable_slot — submit an Enable Slot command TRB to the Command
|
||||
* Ring and ring doorbell 0. Does not wait for or
|
||||
* read the resulting Command Completion Event --
|
||||
* that arrives asynchronously via xhci_poll_events(),
|
||||
* which currently only logs it (Milestone 2e's slot-
|
||||
* ID/context bookkeeping is not wired up yet).
|
||||
*
|
||||
* Returns 0 if the command was posted, -1 if dev/dev->cmd_ring is not set
|
||||
* up (xhci_bringup() has not completed).
|
||||
*/
|
||||
int xhci_cmd_enable_slot(xhci_dev_t *dev);
|
||||
|
||||
#endif /* STARKERNEL_XHCI_DRIVER_H */
|
||||
|
||||
Reference in New Issue
Block a user