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:
Robert Allan James
2026-08-22 09:37:55 -04:00
co-authored by Claude Sonnet 5
parent 2b16daba16
commit 9c8ad8f6ff
11 changed files with 27242 additions and 2 deletions
+17 -1
View File
@@ -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 */