66300cb277
The round-2 stub audit confirmed that the ohcid driver's bulk_transfer and interrupt_transfer (the only OHCI-specific breaking stubs from the v4.8 audit) were NOT fixed by the W1-W8 pass. They returned Err(UsbError::Unsupported) at src/main.rs:275 and :287. This was the single CRITICAL gap left after the previous round. Implementation: bulk_transfer: - Validates endpoint (rejects endpoint 0/control, ep > 15). - Allocates ED + dummy TD + data TD + DMA buffer via the existing alloc_dma helper. - Builds ED hw_info with function address, endpoint number, direction (from TransferDirection; rejects Setup), and max packet size (64 for full-speed bulk). - Builds TD hw_info with TD_CC_NO_ERROR | TD_ROUND | TD_TOGGLE_CARRY | TD_DELAY_INT | direction bits. - Sets ED head_p = data-TD phys, tail_p = dummy phys. - Writes HC_BULK_HEAD_ED and clears HC_BULK_CURRENT_ED. - Ensures CTRL_BLE is set in HC_CONTROL. - Kicks the bulk list by writing HC_CMD_STATUS with CMD_BLF (1<<2). - Polls HC_DONE_HEAD for completion. - Maps TD condition code to UsbError: 4=Stall, 5=NoDevice, 8=Babble, 0xF=Timeout, others=DataError. - Computes actual bytes transferred correctly: hw_cbp==0 means full transfer; otherwise hw_cbp - buf_phys. - For IN transfers, copies data out of the DMA buffer. interrupt_transfer: - Same TD/ED setup as bulk. - Adds 'hcca' (Hcca pointer) and 'hcca_phys' fields to OhciController for periodic ED placement. - Places the ED in HCCA.int_table via periodic-slot selection. Default slot 0 (period 1, every frame) for the synchronous one-shot model. The 32-slot periodic table is walked by the HC via the low 5 bits of the frame number. - Enables PLE (Periodic List Enable) in HC_CONTROL. - A 32-slot periodic table is implemented for proper OHCI semantics (Linux-style balance() pattern: an ED with interval N is inserted into every Nth slot). - Per-interval slot selection picks the least-loaded branch for the given interval. - Polls HC_DONE_HEAD for completion; same error mapping. - For IN transfers, copies data out of the DMA buffer. registers.rs additions: - CMD_CLF = 1<<1 (Control List Filled, for completeness) - CMD_BLF = 1<<2 (Bulk List Filled) - CTRL_PLE = 1<<2 (Periodic List Enable) - TD_CC_* constants expanded for all 16 OHCI condition codes (CRC, BitStuffing, DataToggleMismatch, Stall, DeviceNotResponding, PIDCheckFailure, UnexpectedPID, DataOverrun, DataUnderrun, BufferOverrun, BufferUnderrun, NotAccessed). - TD_DP_IN/OUT direction bit constants. - ED_DIR_IN/OUT direction bit constants. - ED_LOW_SPEED constant. - ED_MAX_PKT_SHIFT constant. - HC_INTERRUPT_STATUS, HC_HCCA, HC_PERIOD_CURRENT_ED, HC_PERIOD_HEAD_ED, HC_PERIOD_BANDWIDTH, HC_DONE_HEAD address constants (for completeness). - HCCA_ALIGN = 256 (OHCI spec: HCCA must be 256-byte aligned). - HCCA_INT_TABLE_OFFSET = 0 (int_table is the first field of HCCA). - NUM_INT_SLOTS = 32 (OHCI spec: 32 interrupt slots). Pure-logic helpers extracted into standalone functions so they can be tested on the host (redox-specific DMA/MMIO paths remain in the methods that actually touch hardware): - validate_data_endpoint(u8) -> Result<u8, UsbError> - ed_direction_bits(TransferDirection) -> Result<u32, UsbError> - build_data_ed_info(...) - build_data_td_info(...) - td_condition_code(hw_info) - td_bytes_transferred(cbp, buf_phys, requested_len) - td_cc_to_usb_error(cc) - periodic_slot_for_interval(interval_ms) - link_periodic_ed(ed_phys, hcca, interval) Tests (15 new, all passing): - validate_endpoint_accepts_numbered_endpoints - validate_endpoint_rejects_control_and_bogus - ed_direction_maps_out_and_in - ed_direction_rejects_setup - build_ed_info_packs_fields - build_td_info_uses_carry_toggle_and_round - build_td_info_out_direction - cc_mapping_matches_linux_ohci - td_condition_code_extract_is_correct - bytes_transferred_full_completion - bytes_transferred_short_read - interrupt_slots_period_one_visits_every_frame - (3 more for periodic slot selection) Cross-reference to Linux 7.1 ohci-hcd.c: - td_fill() pattern (TD_T_TOGGLE | TD_CC | TD_DP_IN/OUT) - BLF (Bulk List Filled) kick via HcCommandStatus - PLE (Periodic List Enable) for interrupt transfer - balance() periodic-slot selection - HC_DONE_HEAD polling pattern Per local/AGENTS.md: - No new branches (work on 0.3.1) - No stubs, no todo!/unimplemented! - Cat 1 in-house recipe - source IS the durable location - No new warnings (verified: same warning count as HEAD) Closes C1 from v4.8 audit. The single CRITICAL gap from the round-2 scan is now fixed.