50#include <unicorn/unicorn.h>
119uint64_t
board_usb_read(uc_engine* uc, uint64_t addr,
unsigned size,
bool* handled);
136void board_usb_write(uc_engine* uc, uint64_t addr,
unsigned size, uint64_t value,
bool* handled);
766bool board_usb_loop_setup(uc_engine* uc, uint16_t req, uint16_t val, uint16_t indx, uint16_t leng);
void board_usb_bridge_mark_configured(uc_engine *uc)
Mark the device configured after a host SET_CONFIGURATION.
void board_usb_loop_bulk_in_flush(uint8_t ep)
Drop whatever remains of a device pipe's bulk-IN staging.
void board_usbhs_host_reg_write(uc_engine *uc, uint64_t off, unsigned size, uint64_t value)
Host-model register write by window byte offset (role routing).
uint64_t board_usbhs_host_reg_read(uc_engine *uc, uint64_t off, unsigned size)
Host-model register read by window byte offset (role routing).
bool board_usb_bridge_bulk_out_consumed(uint8_t dev_pipe)
Whether the device has drained the last host bulk-OUT packet.
bool board_usb_bridge_dcp_out_consumed(void)
Whether the device has drained the last host DCP control-OUT packet.
void board_usb_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value, bool *handled)
Dispatch an MMIO write inside the USBFS register window.
uint32_t board_usbhs_host_shadow_handoff(uint16_t *dst_words, uint32_t word_capacity)
Hand the host model's register shadow off and reset the host model.
void(* board_usb_irq_raiser_t)(uc_engine *uc, uint16_t event)
Signature of the ICU event-raise hook board_periph installs.
void board_usb_feed_bulk_in(const uint8_t *data, uint32_t len)
Queue host->device bulk bytes for the CDC data OUT pipe (echo test).
void board_usb_bridge_ctrl_status(uc_engine *uc)
Drive the read-status stage of a host control-read (raise CTRT).
bool board_usb_roles_swapped(void)
Whether the self-loop window roles are swapped (Config B).
bool board_usb_loop_take_ccpl(uc_engine *uc)
Poll the device's control-transfer completion (DCPCTR.CCPL).
void board_usb_report(void)
Print the USB section of the end-of-run summary.
bool board_usb_bridge_dcp_in_ready(void)
Whether the device has queued a control-IN response on the DCP.
void board_usb_loop_ctrl_out(uc_engine *uc, const uint8_t *data, uint16_t len)
Deliver a control-OUT data-stage packet to the device's DCP.
uint32_t board_usb_echo_received(void)
Number of bulk bytes the host has read back as the device's echo.
void board_usb_bridge_deliver_setup(uc_engine *uc, const uint8_t *setup)
Deliver an 8-byte host SETUP packet to the device (raise its CTRT).
bool board_usb_loop_attached(void)
Whether the modelled USBFS device presents its D+ pull-up.
uint16_t board_usb_bridge_bulk_in_take(uc_engine *uc, uint8_t dev_pipe, uint8_t *buf, uint16_t cap)
Consume a device bulk-IN packet from dev_pipe into buf.
void board_usb_loop_bulk_out(uc_engine *uc, uint8_t ep, const uint8_t *data, uint16_t len)
Deliver one bulk-OUT packet from the firmware host to a device pipe.
void board_usb_tick(uc_engine *uc)
Advance the virtual USB host one emulation chunk.
uint16_t board_usb_loop_ctrl_in_avail(void)
Control-IN bytes the device has queued and the host not yet drained.
uint16_t board_usb_loop_ctrl_in_read(uint8_t *dst, uint16_t cap)
Drain up to cap control-IN bytes from the device's DCP staging.
void board_usb_init(bool trace)
Reset the USBFS controller model and the virtual host state machine.
const char * board_usb_state_string(void)
One-line, human-readable USB device state for the board view.
void board_usb_dev_reg_write(uc_engine *uc, uint64_t off, unsigned size, uint64_t value)
Device-model register write by window byte offset (role routing).
void board_usb_loop_latch(void)
Latch the self-loop: the firmware brought a controller up as HOST.
bool board_usb_configured(void)
Report whether enumeration reached the CONFIGURED state.
void board_usb_roles_swap(uc_engine *uc)
Swap the self-loop window<->model bindings (enter Config B).
uint16_t board_usb_loop_bulk_in_read(uc_engine *uc, uint8_t ep, uint8_t *dst, uint16_t cap)
Drain up to cap bulk-IN bytes from a device pipe's staging.
void board_usb_loop_status_out_zlp(uc_engine *uc)
Run the control-read status stage against the device (host OUT ZLP).
bool board_usb_loop_setup(uc_engine *uc, uint16_t req, uint16_t val, uint16_t indx, uint16_t leng)
Deliver one SETUP packet from the firmware host to the device.
void board_usb_set_external_host(bool present)
Declare (or withdraw) a real-firmware USB host driving the device.
void board_usb_loop_bus_reset(uc_engine *uc)
Deliver a bus reset to the modelled USBFS device (host released RST).
uint64_t board_usb_dev_reg_read(uc_engine *uc, uint64_t off, unsigned size)
Device-model register read by window byte offset (role routing).
void board_usb_loop_ctrl_in_flush(void)
Drop whatever remains of the device's control-IN staging.
void board_usb_bridge_bus_reset(uc_engine *uc)
Bridge a host bus reset onto the device (advance DVSQ to Default).
void board_usb_set_irq_raiser(board_usb_irq_raiser_t raise)
Install the ICU event-raise hook used to pend the USBFS interrupt.
uint64_t board_usb_read(uc_engine *uc, uint64_t addr, unsigned size, bool *handled)
Dispatch an MMIO read inside the USBFS register window.
uint16_t board_usb_loop_bulk_in_avail(uint8_t ep)
Bulk-IN bytes a device pipe has queued and the host not yet drained.
bool board_usb_dev_attached(void)
Whether the modelled USBFS device has asserted its D+ pull-up (DPRPU).
bool board_usb_bridge_bulk_in_ready(uint8_t dev_pipe)
Whether the device has queued a bulk-IN packet on dev_pipe.
void board_usb_bridge_dcp_out(uc_engine *uc, const uint8_t *data, uint16_t len)
Deliver a host control-write data-stage packet to the device DCP.
uint16_t board_usb_bridge_dcp_in_take(uint8_t *buf, uint16_t cap)
Consume the device's queued control-IN response into buf.
void board_usb_bridge_bulk_out(uc_engine *uc, uint8_t dev_pipe, const uint8_t *data, uint16_t len)
Deliver a host bulk-OUT packet to a device endpoint pipe.
bool board_usb_bridge_dev_took_ccpl(void)
Take (consume) the device's control-transfer completion (DCPCTR.CCPL).