|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
USBHS HOST-mode controller model (self-loop peer of the USBFS device). More...
#include <stdint.h>#include <unicorn/unicorn.h>Go to the source code of this file.
Functions | |
| void | board_usb_host_init (bool trace) |
| Reset the USBHS host-mode model to its power-on state. | |
| void | board_usb_host_set_allowed (bool allowed) |
| Grant (or deny) the register-level loop for this firmware. | |
| uint64_t | board_usb_host_read (uc_engine *uc, uint64_t addr, unsigned size, bool *handled) |
| Dispatch an MMIO read inside the USBHS register window. | |
| void | board_usb_host_write (uc_engine *uc, uint64_t addr, unsigned size, uint64_t value, bool *handled) |
| Dispatch an MMIO write inside the USBHS register window. | |
| void | board_usb_host_report (void) |
| Print the USBHS host-model section of the end-of-run summary. | |
USBHS HOST-mode controller model (self-loop peer of the USBFS device).
Models the RA8D2 USB 2.0 High-Speed controller (USBHS, base 0x40351000, HUM Ch 37) in HOST role at register granularity, for firmware that is ITSELF the bus host on the self-loop bench: USBHS (J7) host cabled to USBFS (J11) device, both driven by the same chip (usb_selftest_cdc's topology, and the TrustZone NS image of tz_nsc_cgc_usb). The registers the polled first-party host engine (ra8_usb_host_* in libs/ra8_hal) drives – SYSCFG / DVSTCTR0 / DCPCTR.SUREQ / USBREQ..USBLENG / CFIFO / BRDYSTS / BEMPSTS / INTSTS1 SACK / the PIPESEL window – are serviced here, and every bus transaction is forwarded over the loop-cable transport (board_usb.h board_usb_loop_*) to the modelled USBFS device the device-side firmware is serving.
ENGAGEMENT: the model stays dormant (every access falls through to the sparse register fallback, preserving existing app behaviour byte-for-byte) until BOTH hold:
Modelling boundary: single-packet-in-flight, polled transfers only – what the synchronous ra8_usb_host_* engine issues. A multi-chunk control-OUT data stage overwrites the device's single DCP staging bank if the device firmware does not drain between chunks (no consumer in the EIL suite does this; DFU class flows stay on their C-level seams).
Definition in file board_usb_host.h.
| void board_usb_host_init | ( | bool | trace | ) |
Reset the USBHS host-mode model to its power-on state.
Clears the register shadows, the per-pipe configuration window, the FIFO staging and the engagement latch. Call once from board_periph_init before the run loop, next to board_usb_init.
| [in] | trace | When true, each loop-cable transaction is logged to injected error sink. |
Definition at line 789 of file board_usb_host.c.
References s_hs, and s_hs_trace.
Referenced by board_periph_init().
| uint64_t board_usb_host_read | ( | uc_engine * | uc, |
| uint64_t | addr, | ||
| unsigned | size, | ||
| bool * | handled ) |
Dispatch an MMIO read inside the USBHS register window.
| [in,out] | uc | Unicorn engine (loop-cable calls pend device IRQs). |
| [in] | addr | Absolute peripheral address being read. |
| [in] | size | Access width in bytes (1 / 2 / 4). |
| [out] | handled | True iff the model is engaged and addr is inside the USBHS window. |
*handled is true, else 0. Dispatch an mmio read inside the usbhs register window; this step is contained within the board USB host model and uses bounded caller or module-owned storage.
| value | The operation-specific board USB host read value. |
Definition at line 800 of file board_usb_host.c.
References internal_usbhs_reg_read(), k_usbhs_base, k_usbhs_span, and s_hs.
Referenced by board_periph_read().
| void board_usb_host_report | ( | void | ) |
Print the USBHS host-model section of the end-of-run summary.
Silent unless the model engaged; then reports the SETUP / bulk transaction totals the firmware host drove over the loop.
Definition at line 843 of file board_usb_host.c.
References priv_emu_io_errf(), and s_hs.
Referenced by board_periph_report().
| void board_usb_host_set_allowed | ( | bool | allowed | ) |
Grant (or deny) the register-level loop for this firmware.
main.c calls this after its usb-host seam installer ran: when a C-level seam (virtual keyboard / virtual MSC disk) was installed for the firmware's host API, the register path is shadowed by those seams and this model must stay dormant so seamed apps keep their exact current behaviour. Only an unseamed firmware (e.g. the TrustZone NS image, whose symbols the seam installer never scans) gets the register-level loop.
| [in] | allowed | true to allow engagement on a host-mode SYSCFG write. |
allowed false the model never claims the window this run. Definition at line 795 of file board_usb_host.c.
References s_hs.
Referenced by internal_main_install_run_seams().
| void board_usb_host_write | ( | uc_engine * | uc, |
| uint64_t | addr, | ||
| unsigned | size, | ||
| uint64_t | value, | ||
| bool * | handled ) |
Dispatch an MMIO write inside the USBHS register window.
Pre-engagement, only the SYSCFG word is watched (for the DCFM host-role select that engages the model); the write still reports unhandled so the sparse fallback keeps recording it, preserving the behaviour of every USBHS app that never engages.
| [in,out] | uc | Unicorn engine (loop-cable calls pend device IRQs). |
| [in] | addr | Absolute peripheral address being written. |
| [in] | size | Access width in bytes (1 / 2 / 4). |
| [in] | value | Value being written. |
| [out] | handled | True iff the model is engaged and consumed the write. |
Definition at line 811 of file board_usb_host.c.
References board_usb_loop_latch(), internal_usbhs_reg_write(), internal_usbhs_word(), k_ra8_syscfg_bit_dcfm, k_ra8_usb_off_syscfg, k_usbhs_base, k_usbhs_span, priv_emu_io_errf(), and s_hs.
Referenced by board_periph_write().