|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
On-chip USBHS host controller model (0x40351000) for the board emulator. More...
#include <stdint.h>#include <stdio.h>#include <string.h>#include "board_periph_block.h"#include "board_usb.h"#include "emu_host_io_internal.h"#include "ra8_usb_regs.h"Go to the source code of this file.
Data Structures | |
| struct | usbhs_state_t |
| Aggregate USBHS host-controller model state. More... | |
Enumerations | |
| enum | usbhs_geom_t : uint64_t { k_usbhs_base = 0x40351000UL , k_usbhs_span = 0x200UL , k_usbhs_words = 0x200UL / 2U , k_usbhs_dev_span = 0x100UL , k_usbhs_pipes = 10UL , k_usbhs_pkt_cap = 512UL , k_usbhs_din_cap = 512UL , k_usbhs_setup_len = 8UL , k_usbhs_report_ord = 155UL } |
| USBHS host register-window geometry and staging-buffer caps. More... | |
| enum | usbhs_lines_t : uint16_t { k_usbhs_lnst_j = 0x0001U , k_usbhs_rhst_fs = 0x0002U } |
| SYSSTS0 / DVSTCTR0 host-role line-state fields (HUM Ch 37.2.3 / 37.2.5). More... | |
| enum | usbhs_dvstctr_bit_t : uint8_t { k_usbhs_dvstctr_usbrst = 6U } |
| DVSTCTR0 host-control bit positions (HUM Ch 37.2.5, p 2065). More... | |
| enum | usbhs_pllsta_bit_t : uint16_t { k_usbhs_plllock = 0x0001U } |
| PLLSTA lock flag reported so the firmware's PHY PLL wait completes. More... | |
| enum | usbhs_status_bit_t : uint16_t { k_usbhs_dcp_bit = 0x0001U } |
| DCP (pipe 0) status bit shared by BRDYSTS / BEMPSTS / NRDYSTS. More... | |
| enum | usbhs_usb_std_t : uint8_t { k_usbhs_setup_dir_in = 0x80U , k_usbhs_breq_set_addr = 0x05U , k_usbhs_breq_set_config = 0x09U } |
| Standard USB chapter-9 SETUP field values the model classifies on. More... | |
| enum | usbhs_lit_t : uint32_t { k_usbhs_byte_bits = 8U , k_usbhs_byte_mask = 0xFFU , k_usbhs_epnum_mask = 0x0FU , k_usbhs_cfifo_h = 2U , k_usbhs_cfifo_hh = 3U } |
| Small shared literals (avoid bare numeric literals). More... | |
| enum | usbhs_setup_idx_t : uint8_t { k_usbhs_setup_bmrt = 0U , k_usbhs_setup_breq = 1U , k_usbhs_setup_wval_lo = 2U , k_usbhs_setup_wval_hi = 3U , k_usbhs_setup_widx_lo = 4U , k_usbhs_setup_widx_hi = 5U , k_usbhs_setup_wlen_lo = 6U , k_usbhs_setup_wlen_hi = 7U } |
| SETUP-packet byte offsets (USB 2.0 sec 9.3, little-endian fields). More... | |
Functions | |
| static uint32_t | internal_hs_word (uint64_t off) |
| 16-bit shadow word index for a window byte offset. | |
| static uint16_t | internal_hs_reg (uint16_t off) |
Read a 16-bit shadow register at window byte offset off. | |
| static void | internal_hs_set (uint16_t off, uint16_t value) |
Write a 16-bit shadow register at window byte offset off. | |
| static void | internal_hs_or (uint16_t off, uint16_t bits) |
OR bits into the 16-bit shadow register at off. | |
| static uint8_t | internal_hs_curpipe (void) |
| Currently-selected CFIFO pipe (CFIFOSEL.CURPIPE[3:0], modulo pipe count). | |
| static uint8_t | internal_hs_pipesel (void) |
| The host pipe currently selected by PIPESEL (modulo pipe count). | |
| static bool | internal_hs_is_pipectr (uint64_t off) |
True when off is inside the PIPECTR[9] array window. | |
| static uint8_t | internal_hs_pipectr_index (uint64_t off) |
PIPECTR array index (PIPE1..PIPE9, modulo pipe count) for off. | |
| static uint16_t | internal_hs_cfifo_dtln (void) |
| Bytes still available for the host to read on the selected IN staging. | |
| static void | internal_hs_cfifo_write (uint32_t value, unsigned size) |
Append size bytes of value (LSB-first) to the selected OUT pipe. | |
| static uint32_t | internal_hs_cfifo_read (unsigned size) |
Read size bytes (LSB-first) from the selected IN staging buffer. | |
| static void | internal_hs_bulk_out_commit (uc_engine *uc) |
| Deliver the selected bulk pipe's accumulated OUT payload to the device. | |
| static uint16_t | internal_hs_bempsts_read (void) |
| BEMPSTS read: raise a pipe's BEMP once the device has drained its OUT packet. | |
| static void | internal_hs_ctrl_status_complete (uc_engine *uc) |
| Finish a no-data / control-write IN status stage. | |
| static uint16_t | internal_hs_brdysts_read (uc_engine *uc) |
| Latch any device IN data the host is now polling for (BRDY sources). | |
| static void | internal_hs_brdysts_write (uint16_t value) |
| Apply a BRDYSTS W0C write: a written 0 clears that bit, a 1 preserves it. | |
| static void | internal_hs_capture_setup (void) |
| Copy USBREQ..USBLENG from the shadow into the 8-byte SETUP buffer. | |
| static void | internal_hs_setup_launch (uc_engine *uc) |
| Launch a SETUP (DCPCTR.SUREQ write): deliver it and latch SACK. | |
| static void | internal_hs_ccpl_status (uc_engine *uc) |
| Handle a DCPCTR.CCPL rising edge: drive the control-transfer status stage. | |
| static void | internal_hs_dcpctr_write (uc_engine *uc, uint16_t value) |
| Apply a DCPCTR write: SUREQ launches a SETUP, CCPL drives the status. | |
| static void | internal_hs_cfifoctr_write (uc_engine *uc, uint16_t value) |
| Apply a CFIFOCTR write: BCLR flushes the buffer, BVAL commits a bulk OUT. | |
| static void | internal_hs_dvstctr0_write (uc_engine *uc, uint16_t value) |
| Apply a DVSTCTR0 write, bridging a host bus-reset edge onto the device. | |
| static uint64_t | internal_hs_read (uc_engine *uc, uint64_t off, unsigned size) |
Read one USBHS host register at window byte offset off. | |
| static void | internal_hs_write (uc_engine *uc, uint64_t off, unsigned size, uint64_t value) |
Write one USBHS host register at window byte offset off. | |
| 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). | |
| 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). | |
| 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. | |
| static uint64_t | internal_usbhs_block_read (uc_engine *uc, uint64_t addr, unsigned size) |
| MMIO read handler: dispatch inside the USBHS controller window. | |
| static void | internal_usbhs_block_write (uc_engine *uc, uint64_t addr, unsigned size, uint64_t value) |
| MMIO write handler: dispatch inside the USBHS controller window. | |
| static void | internal_usbhs_reset (void) |
| Reset the USBHS host model to power-on state. | |
| static void | internal_usbhs_report (void) |
| End-of-run summary: enumeration + bulk traffic bridged to the device. | |
| static void | internal_usbhs_block_register (void) |
| Register the USBHS host block before main (host constructor). | |
Variables | |
| static usbhs_state_t | s_hs |
| static const board_periph_block_t | s_k_usbhs_block |
| USBHS host block descriptor (loop-only: owns 0x40351000 with –usbhs-loop). | |
On-chip USBHS host controller model (0x40351000) for the board emulator.
Models the RA8D2 USB 2.0 High-Speed controller (USBHS, base 0x40351000, HUM Ch 37) in HOST role – the missing half of the chip-internal USB self-loop. board_usb.c already models the USBFS controller (0x40250000) in DEVICE role; this block models the second on-chip controller acting as the HOST that enumerates and talks to that device, exactly as the EK-RA8D2's two USB jacks do when cabled to each other on the bench. Together they close the loop the usb_selftest_* / dfu_selftest_* apps exercise, entirely in-process.
The firmware's first-party host driver (libs/ra8_hal ra8_usb_host_*) is polled: it programs the host registers here and spins on their status bits (SACK on INTSTS1, BRDY/BEMP on BRDYSTS/BEMPSTS, SUREQ self-clear on DCPCTR) rather than taking a host interrupt. So this model is purely reactive – it answers the firmware's register reads and, on the writes that launch a transfer (SUREQ, a bulk BVAL, a CCPL), calls the board_usb.c bridge to drive the DEVICE model: deliver the SETUP + raise the device CTRT, stage the host's OUT bytes into the device's OUT pipe + raise BRDY, or collect the device's IN response. The device firmware's own ISR runs (preempting the host's spin via SysTick/PendSV, the higher-priority device worker) and fills its side of the FIFO, which this model reflects back to the host as the descriptor / echo bytes. No host interrupt, no second Unicorn core – one image, both stacks, a modelled cable.
This block only owns its window when ra8_emulator is started with --usbhs-loop (board_periph_block_t::loop_only): without the flag the window falls through to the sparse fallback, so the existing ra8_usb_host_* function-intercept seam (main.c, the virtual HID keyboard / MSC disk for host-only apps) is untouched. A self-loop app opts in through its hil.conf's HIL_EMU_ARGS.
Register offsets and bit fields come from ra8_usb_regs.h (the same first-party HUM transcription the driver uses). The few host-role fields not carried there (SYSSTS0.LNST line state, DVSTCTR0.USBRST/UACT/RHST, PLLSTA lock) are defined locally and flagged with a [CONFIRM] note where the value comes from general USB2_B knowledge rather than a direct HUM transcription.
Definition in file board_periph_usbhs_host.c.
| enum usbhs_dvstctr_bit_t : uint8_t |
DVSTCTR0 host-control bit positions (HUM Ch 37.2.5, p 2065).
| Enumerator | |
|---|---|
| k_usbhs_dvstctr_usbrst | USBRST: drive bus reset. [CONFIRM] HUM Ch 37.2.5. |
Definition at line 85 of file board_periph_usbhs_host.c.
| enum usbhs_geom_t : uint64_t |
USBHS host register-window geometry and staging-buffer caps.
Definition at line 59 of file board_periph_usbhs_host.c.
| enum usbhs_lines_t : uint16_t |
SYSSTS0 / DVSTCTR0 host-role line-state fields (HUM Ch 37.2.3 / 37.2.5).
| Enumerator | |
|---|---|
| k_usbhs_lnst_j | SYSSTS0.LNST J-state: an FS device is attached. [CONFIRM] general USB2_B LNST encoding. |
| k_usbhs_rhst_fs | DVSTCTR0.RHST = full speed. [CONFIRM] driver comment (01=LS,10=FS,11=HS) in ra8_usb_host_ctrl.c. |
Definition at line 77 of file board_periph_usbhs_host.c.
| enum usbhs_lit_t : uint32_t |
Small shared literals (avoid bare numeric literals).
Definition at line 107 of file board_periph_usbhs_host.c.
| enum usbhs_pllsta_bit_t : uint16_t |
PLLSTA lock flag reported so the firmware's PHY PLL wait completes.
| Enumerator | |
|---|---|
| k_usbhs_plllock | PLLSTA.PLLLOCK (HUM Ch 37.2.4 "PLLSTA" p 2064). |
Definition at line 90 of file board_periph_usbhs_host.c.
| enum usbhs_setup_idx_t : uint8_t |
SETUP-packet byte offsets (USB 2.0 sec 9.3, little-endian fields).
Definition at line 116 of file board_periph_usbhs_host.c.
| enum usbhs_status_bit_t : uint16_t |
DCP (pipe 0) status bit shared by BRDYSTS / BEMPSTS / NRDYSTS.
| Enumerator | |
|---|---|
| k_usbhs_dcp_bit | BRDYSTS/BEMPSTS/NRDYSTS DCP (pipe 0) bit. |
Definition at line 95 of file board_periph_usbhs_host.c.
| enum usbhs_usb_std_t : uint8_t |
Standard USB chapter-9 SETUP field values the model classifies on.
Definition at line 100 of file board_periph_usbhs_host.c.
| 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).
Exported by board_periph_usbhs_host.c so the USBFS window claim in board_usb.c can route its reads into the host model when the roles are swapped (Config B: the polled ra8_usb_host_* driver runs on the USBFS controller).
| [in,out] | uc | Unicorn engine (bulk/control latching pends device IRQs). |
| [in] | off | Byte offset inside the controller register window. |
| [in] | size | Access width in bytes (1, 2 or 4). |
off is inside the host model's 0x200-byte register span. | value | The operation-specific board usbhs host reg read value. |
Definition at line 818 of file board_periph_usbhs_host.c.
References internal_hs_read().
Referenced by board_usb_read().
| 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).
Exported by board_periph_usbhs_host.c so the USBFS window claim in board_usb.c can route its writes into the host model when the roles are swapped (Config B).
| [in,out] | uc | Unicorn engine (transfer launches drive the device model). |
| [in] | off | Byte offset inside the controller register window. |
| [in] | size | Access width in bytes (1, 2 or 4). |
| [in] | value | Value the firmware wrote. |
off is inside the host model's 0x200-byte register span. Definition at line 823 of file board_periph_usbhs_host.c.
References internal_hs_write().
Referenced by board_usb_write().
| 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.
Role-swap migration primitive (board_periph_usbhs_host.c): copies up to word_capacity 16-bit shadow words – the USBHS window's accumulated writes, i.e. the device firmware's PHY + module-init register state – into dst_words, then resets the entire host model so it starts virgin behind the USBFS window. Called exactly once, by board_usb_roles_swap.
| [out] | dst_words | Destination for the 16-bit shadow words. |
| [in] | word_capacity | Capacity of dst_words in 16-bit words. |
dst_words is non-NULL with room for word_capacity words. | value | The operation-specific board usbhs host shadow handoff value. |
Definition at line 828 of file board_periph_usbhs_host.c.
References k_usbhs_dev_span, k_usbhs_words, memcpy(), and s_hs.
Referenced by board_usb_roles_swap().
|
static |
BEMPSTS read: raise a pipe's BEMP once the device has drained its OUT packet.
Bempsts read: raise a pipe's bemp once the device has drained its out packet; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| value | The operation-specific hs bempsts read value. |
Definition at line 416 of file board_periph_usbhs_host.c.
References board_usb_bridge_bulk_out_consumed(), board_usb_bridge_dcp_out_consumed(), internal_hs_or(), internal_hs_reg(), k_ra8_usb_off_bempsts, k_usbhs_dcp_bit, k_usbhs_pipes, RA8_INTERNAL, and s_hs.
Referenced by internal_hs_read().
|
static |
Latch any device IN data the host is now polling for (BRDY sources).
Called on every BRDYSTS read – the register the polled host driver spins on. First completes a deferred no-data control-write status stage once the device has pulsed its CCPL (so the host does not race past a request the device is still applying). Then reflects the device's control-IN response into din and any armed bulk-IN pipe's echo into pin, setting the matching BRDYSTS bit. The guards (din_ready / pin_ready, PID==BUF) latch each packet once, only after the host armed the transfer and the device produced the data.
| [in,out] | uc | Unicorn engine (bulk-IN collection pends the device BEMP). |
| value | The operation-specific hs brdysts read value. |
Definition at line 476 of file board_periph_usbhs_host.c.
References board_usb_bridge_bulk_in_ready(), board_usb_bridge_bulk_in_take(), board_usb_bridge_dcp_in_ready(), board_usb_bridge_dcp_in_take(), board_usb_bridge_dev_took_ccpl(), internal_hs_ctrl_status_complete(), internal_hs_or(), internal_hs_reg(), k_ra8_pid_buf, k_ra8_pid_mask, k_ra8_usb_off_brdysts, k_usbhs_dcp_bit, k_usbhs_din_cap, k_usbhs_pipes, k_usbhs_pkt_cap, RA8_INTERNAL, and s_hs.
Referenced by internal_hs_read().
|
static |
Apply a BRDYSTS W0C write: a written 0 clears that bit, a 1 preserves it.
Apply a brdysts w0c write: a written 0 clears that bit, a 1 preserves it; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in] | value | Register or payload value involved in the operation. |
Definition at line 513 of file board_periph_usbhs_host.c.
References internal_hs_reg(), internal_hs_set(), k_ra8_usb_off_brdysts, k_usbhs_dcp_bit, k_usbhs_pipes, RA8_INTERNAL, and s_hs.
Referenced by internal_hs_write().
|
static |
Deliver the selected bulk pipe's accumulated OUT payload to the device.
Deliver the selected bulk pipe's accumulated out payload to the device; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
Definition at line 381 of file board_periph_usbhs_host.c.
References board_usb_bridge_bulk_out(), board_usb_bridge_dcp_out(), internal_hs_curpipe(), RA8_INTERNAL, and s_hs.
Referenced by internal_hs_cfifoctr_write().
|
static |
Copy USBREQ..USBLENG from the shadow into the 8-byte SETUP buffer.
Copy usbreq..usbleng from the shadow into the 8-byte setup buffer; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
Definition at line 540 of file board_periph_usbhs_host.c.
References internal_hs_reg(), k_ra8_usb_off_usbindx, k_ra8_usb_off_usbleng, k_ra8_usb_off_usbreq, k_ra8_usb_off_usbval, k_usbhs_byte_bits, k_usbhs_byte_mask, k_usbhs_setup_bmrt, k_usbhs_setup_breq, k_usbhs_setup_widx_hi, k_usbhs_setup_widx_lo, k_usbhs_setup_wlen_hi, k_usbhs_setup_wlen_lo, k_usbhs_setup_wval_hi, k_usbhs_setup_wval_lo, RA8_INTERNAL, and s_hs.
Referenced by internal_hs_setup_launch().
|
static |
Handle a DCPCTR.CCPL rising edge: drive the control-transfer status stage.
Handle a dcpctr.ccpl rising edge: drive the control-transfer status stage; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
Definition at line 600 of file board_periph_usbhs_host.c.
References board_usb_bridge_ctrl_status(), internal_hs_ctrl_status_complete(), internal_hs_or(), k_ra8_usb_off_bempsts, k_usbhs_breq_set_addr, k_usbhs_dcp_bit, RA8_INTERNAL, and s_hs.
Referenced by internal_hs_dcpctr_write().
|
static |
Bytes still available for the host to read on the selected IN staging.
Bytes still available for the host to read on the selected in staging; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| value | The operation-specific hs cfifo dtln value. |
Definition at line 311 of file board_periph_usbhs_host.c.
References internal_hs_curpipe(), RA8_INTERNAL, and s_hs.
Referenced by internal_hs_read().
|
static |
Read size bytes (LSB-first) from the selected IN staging buffer.
Read size bytes (lsb-first) from the selected in staging buffer; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in] | size | Size of the requested region or access in bytes. |
| value | The operation-specific hs cfifo read value. |
Definition at line 354 of file board_periph_usbhs_host.c.
References internal_hs_curpipe(), k_usbhs_byte_bits, RA8_INTERNAL, and s_hs.
Referenced by internal_hs_read().
|
static |
Append size bytes of value (LSB-first) to the selected OUT pipe.
Append size bytes of value (lsb-first) to the selected out pipe; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in] | value | Register or payload value involved in the operation. |
| [in] | size | Size of the requested region or access in bytes. |
Definition at line 334 of file board_periph_usbhs_host.c.
References internal_hs_curpipe(), k_usbhs_byte_bits, k_usbhs_byte_mask, k_usbhs_pkt_cap, RA8_INTERNAL, and s_hs.
Referenced by internal_hs_write().
|
static |
Apply a CFIFOCTR write: BCLR flushes the buffer, BVAL commits a bulk OUT.
Apply a cfifoctr write: bclr flushes the buffer, bval commits a bulk out; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
| [in] | value | Register or payload value involved in the operation. |
Definition at line 667 of file board_periph_usbhs_host.c.
References internal_hs_bulk_out_commit(), internal_hs_curpipe(), k_ra8_fifoctr_bclr, k_ra8_fifoctr_bval, RA8_INTERNAL, and s_hs.
Referenced by internal_hs_write().
|
static |
Finish a no-data / control-write IN status stage.
Presents the device's status ZLP as a zero-length DCP IN packet so the polled host's status-stage BRDY wait (internal_host_dcp_in_wait) returns, and – for SET_CONFIGURATION – advances the device model to the Configured state. Shared by the immediate path (SIE-owned SET_ADDRESS, and control writes that carried a data stage) and the deferred path that waits on the device's DCPCTR.CCPL.
| [in,out] | uc | Unicorn engine (mark-configured pends the device DVST IRQ). |
Definition at line 446 of file board_periph_usbhs_host.c.
References board_usb_bridge_mark_configured(), internal_hs_or(), k_ra8_usb_off_brdysts, k_usbhs_breq_set_config, k_usbhs_dcp_bit, RA8_INTERNAL, and s_hs.
Referenced by internal_hs_brdysts_read(), and internal_hs_ccpl_status().
|
static |
Currently-selected CFIFO pipe (CFIFOSEL.CURPIPE[3:0], modulo pipe count).
Currently-selected cfifo pipe (cfifosel.curpipe[3:0], modulo pipe count); this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| value | The operation-specific hs curpipe value. |
Definition at line 248 of file board_periph_usbhs_host.c.
References internal_hs_reg(), k_ra8_fifosel_curpipe, k_ra8_usb_off_cfifosel, k_usbhs_pipes, and RA8_INTERNAL.
Referenced by internal_hs_bulk_out_commit(), internal_hs_cfifo_dtln(), internal_hs_cfifo_read(), internal_hs_cfifo_write(), and internal_hs_cfifoctr_write().
|
static |
Apply a DCPCTR write: SUREQ launches a SETUP, CCPL drives the status.
Apply a dcpctr write: sureq launches a setup, ccpl drives the status; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
| [in] | value | Register or payload value involved in the operation. |
Definition at line 638 of file board_periph_usbhs_host.c.
References internal_hs_ccpl_status(), internal_hs_reg(), internal_hs_set(), internal_hs_setup_launch(), k_ra8_dcpctr_bit_ccpl, k_ra8_dcpctr_bit_sureq, k_ra8_usb_off_dcpctr, and RA8_INTERNAL.
Referenced by internal_hs_write().
|
static |
Apply a DVSTCTR0 write, bridging a host bus-reset edge onto the device.
Apply a dvstctr0 write, bridging a host bus-reset edge onto the device; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
| [in] | value | Register or payload value involved in the operation. |
Definition at line 694 of file board_periph_usbhs_host.c.
References board_usb_bridge_bus_reset(), internal_hs_set(), k_ra8_usb_off_dvstctr0, k_usbhs_dvstctr_usbrst, RA8_INTERNAL, and s_hs.
Referenced by internal_hs_write().
|
static |
True when off is inside the PIPECTR[9] array window.
True when off is inside the pipectr[9] array window; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in] | off | Register or byte offset addressed by the operation. |
| true | The hs is pipectr condition holds or completed successfully; false otherwise. |
Definition at line 279 of file board_periph_usbhs_host.c.
References k_ra8_usb_off_pipectr, k_ra8_usb_pipectr_count, and RA8_INTERNAL.
Referenced by internal_hs_read(), and internal_hs_write().
|
static |
OR bits into the 16-bit shadow register at off.
Or bits into the 16-bit shadow register at off; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in] | off | Register or byte offset addressed by the operation. |
| [in] | bits | Bits input used by the operation. |
Definition at line 234 of file board_periph_usbhs_host.c.
References internal_hs_reg(), internal_hs_set(), and RA8_INTERNAL.
Referenced by internal_hs_bempsts_read(), internal_hs_brdysts_read(), internal_hs_ccpl_status(), internal_hs_ctrl_status_complete(), and internal_hs_setup_launch().
|
static |
PIPECTR array index (PIPE1..PIPE9, modulo pipe count) for off.
Pipectr array index (pipe1..pipe9, modulo pipe count) for off; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in] | off | Register or byte offset addressed by the operation. |
| value | The operation-specific hs pipectr index value. |
Definition at line 296 of file board_periph_usbhs_host.c.
References k_ra8_usb_off_pipectr, k_usbhs_pipes, and RA8_INTERNAL.
Referenced by internal_hs_read(), and internal_hs_write().
|
static |
The host pipe currently selected by PIPESEL (modulo pipe count).
The host pipe currently selected by pipesel (modulo pipe count); this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| value | The operation-specific hs pipesel value. |
Definition at line 264 of file board_periph_usbhs_host.c.
References internal_hs_reg(), k_ra8_usb_off_pipesel, k_usbhs_pipes, and RA8_INTERNAL.
Referenced by internal_hs_read(), and internal_hs_write().
|
static |
Read one USBHS host register at window byte offset off.
Read one usbhs host register at window byte offset off; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
| [in] | off | Register or byte offset addressed by the operation. |
| [in] | size | Size of the requested region or access in bytes. |
| value | The operation-specific hs read value. |
Definition at line 721 of file board_periph_usbhs_host.c.
References board_usb_dev_attached(), internal_hs_bempsts_read(), internal_hs_brdysts_read(), internal_hs_cfifo_dtln(), internal_hs_cfifo_read(), internal_hs_is_pipectr(), internal_hs_pipectr_index(), internal_hs_pipesel(), internal_hs_reg(), k_ra8_fifoctr_dtln, k_ra8_fifoctr_frdy, k_ra8_usb_off_bempsts, k_ra8_usb_off_brdysts, k_ra8_usb_off_cfifo, k_ra8_usb_off_cfifoctr, k_ra8_usb_off_dvstctr0, k_ra8_usb_off_pipemaxp, k_ra8_usb_off_syssts0, k_ra8_usbhs_off_pllsta, k_usbhs_lnst_j, k_usbhs_plllock, k_usbhs_rhst_fs, RA8_INTERNAL, and s_hs.
Referenced by board_usbhs_host_reg_read(), and internal_usbhs_block_read().
|
static |
Read a 16-bit shadow register at window byte offset off.
Read a 16-bit shadow register at window byte offset off; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in] | off | Register or byte offset addressed by the operation. |
| value | The operation-specific hs reg value. |
Definition at line 206 of file board_periph_usbhs_host.c.
References internal_hs_word(), RA8_INTERNAL, and s_hs.
Referenced by internal_hs_bempsts_read(), internal_hs_brdysts_read(), internal_hs_brdysts_write(), internal_hs_capture_setup(), internal_hs_curpipe(), internal_hs_dcpctr_write(), internal_hs_or(), internal_hs_pipesel(), internal_hs_read(), internal_hs_setup_launch(), internal_hs_write(), and internal_usbhs_block_read().
|
static |
Write a 16-bit shadow register at window byte offset off.
Write a 16-bit shadow register at window byte offset off; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in] | off | Register or byte offset addressed by the operation. |
| [in] | value | Register or payload value involved in the operation. |
Definition at line 220 of file board_periph_usbhs_host.c.
References internal_hs_word(), RA8_INTERNAL, and s_hs.
Referenced by internal_hs_brdysts_write(), internal_hs_dcpctr_write(), internal_hs_dvstctr0_write(), internal_hs_or(), internal_hs_write(), and internal_usbhs_block_write().
|
static |
Launch a SETUP (DCPCTR.SUREQ write): deliver it and latch SACK.
Launch a setup (dcpctr.sureq write): deliver it and latch sack; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
Definition at line 568 of file board_periph_usbhs_host.c.
References board_usb_bridge_deliver_setup(), board_usb_bridge_dev_took_ccpl(), internal_hs_capture_setup(), internal_hs_or(), internal_hs_reg(), k_ra8_int1_bit_sack, k_ra8_usb_off_intsts1, k_ra8_usb_off_usbleng, k_usbhs_setup_bmrt, k_usbhs_setup_breq, k_usbhs_setup_dir_in, RA8_INTERNAL, and s_hs.
Referenced by internal_hs_dcpctr_write().
|
static |
16-bit shadow word index for a window byte offset.
16-bit shadow word index for a window byte offset; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in] | off | Register or byte offset addressed by the operation. |
| value | The operation-specific hs word value. |
Definition at line 191 of file board_periph_usbhs_host.c.
References RA8_INTERNAL.
Referenced by internal_hs_reg(), and internal_hs_set().
|
static |
Write one USBHS host register at window byte offset off.
Write one usbhs host register at window byte offset off; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
| [in,out] | uc | Unicorn engine whose emulated state is read or updated. |
| [in] | off | Register or byte offset addressed by the operation. |
| [in] | size | Size of the requested region or access in bytes. |
| [in] | value | Register or payload value involved in the operation. |
Definition at line 767 of file board_periph_usbhs_host.c.
References internal_hs_brdysts_write(), internal_hs_cfifo_write(), internal_hs_cfifoctr_write(), internal_hs_dcpctr_write(), internal_hs_dvstctr0_write(), internal_hs_is_pipectr(), internal_hs_pipectr_index(), internal_hs_pipesel(), internal_hs_reg(), internal_hs_set(), k_ra8_usb_off_bempsts, k_ra8_usb_off_brdysts, k_ra8_usb_off_cfifo, k_ra8_usb_off_cfifoctr, k_ra8_usb_off_dcpctr, k_ra8_usb_off_dvstctr0, k_ra8_usb_off_intsts0, k_ra8_usb_off_intsts1, k_ra8_usb_off_nrdysts, k_ra8_usb_off_pipecfg, k_ra8_usb_off_pipemaxp, k_usbhs_cfifo_h, k_usbhs_cfifo_hh, k_usbhs_epnum_mask, and s_hs.
Referenced by board_usbhs_host_reg_write(), and internal_usbhs_block_write().
|
static |
MMIO read handler: dispatch inside the USBHS controller window.
The embedded HS PHY page is role-agnostic and always answered here: PLLSTA reports the UTMI PLL locked so either role's PHY bring-up completes, and offsets past the device model's 0x100-byte span (LPSTS at 0x102) reflect the local shadow. Everything else routes by the self-loop polarity: to the host model (Config A, default) or to the device model after a role swap (Config B: the DCD drives this controller in device role).
| [in,out] | uc | Unicorn engine (forwarded to the routed model). |
| [in] | addr | Absolute MMIO address inside the window. |
| [in] | size | Access width in bytes. |
| value | The operation-specific usbhs block read value. |
Definition at line 874 of file board_periph_usbhs_host.c.
References board_usb_dev_reg_read(), board_usb_roles_swapped(), internal_hs_read(), internal_hs_reg(), k_ra8_usbhs_off_pllsta, k_usbhs_base, k_usbhs_dev_span, k_usbhs_plllock, and RA8_INTERNAL.
|
static |
Register the USBHS host block before main (host constructor).
Definition at line 978 of file board_periph_usbhs_host.c.
References board_periph_register_block(), RA8_INTERNAL, and s_k_usbhs_block.
|
static |
MMIO write handler: dispatch inside the USBHS controller window.
Watches for the firmware's device-role declaration – a SYSCFG write with DPRPU=1 (the D+ pull-up only a device asserts, HUM Ch 37.2.1) – and swaps the self-loop window<->model bindings on it (Config B). PHY-page writes past the device model's span (LPSTS) always land in the local shadow; everything else routes by the current polarity.
| [in,out] | uc | Unicorn engine (forwarded to the routed model). |
| [in] | addr | Absolute MMIO address inside the window. |
| [in] | size | Access width in bytes. |
| [in] | value | Value the firmware wrote. |
Definition at line 908 of file board_periph_usbhs_host.c.
References board_usb_dev_reg_write(), board_usb_roles_swap(), board_usb_roles_swapped(), internal_hs_set(), internal_hs_write(), k_ra8_syscfg_bit_dprpu, k_ra8_usb_off_syscfg, k_usbhs_base, and k_usbhs_dev_span.
|
static |
End-of-run summary: enumeration + bulk traffic bridged to the device.
End-of-run summary: enumeration + bulk traffic bridged to the device; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
Definition at line 948 of file board_periph_usbhs_host.c.
References board_usb_roles_swapped(), priv_emu_io_errf(), RA8_INTERNAL, and s_hs.
|
static |
Reset the USBHS host model to power-on state.
Reset the usbhs host model to power-on state; this step is contained within the board periph usbhs host model and uses bounded caller or module-owned storage.
Definition at line 936 of file board_periph_usbhs_host.c.
References RA8_INTERNAL, and s_hs.
|
static |
Definition at line 174 of file board_periph_usbhs_host.c.
Referenced by board_usb_host_init(), board_usb_host_read(), board_usb_host_report(), board_usb_host_set_allowed(), board_usb_host_write(), board_usbhs_host_shadow_handoff(), internal_hs_bempsts_read(), internal_hs_brdysts_read(), internal_hs_brdysts_write(), internal_hs_bulk_out_commit(), internal_hs_capture_setup(), internal_hs_ccpl_status(), internal_hs_cfifo_dtln(), internal_hs_cfifo_read(), internal_hs_cfifo_write(), internal_hs_cfifoctr_write(), internal_hs_ctrl_status_complete(), internal_hs_dvstctr0_write(), internal_hs_read(), internal_hs_reg(), internal_hs_set(), internal_hs_setup_launch(), internal_hs_write(), internal_usbhs_brdysts_value(), internal_usbhs_cfifo_isel(), internal_usbhs_cfifo_read(), internal_usbhs_cfifo_write(), internal_usbhs_cfifoctr_write(), internal_usbhs_cur_pipe(), internal_usbhs_dcp_mps(), internal_usbhs_dcpctr_write(), internal_usbhs_do_ccpl(), internal_usbhs_do_setup(), internal_usbhs_dvstctr_write(), internal_usbhs_pipe_ep(), internal_usbhs_pipe_is_tx(), internal_usbhs_pipe_mps(), internal_usbhs_reg_read(), internal_usbhs_reg_write(), internal_usbhs_report(), and internal_usbhs_reset().
|
static |
USBHS host block descriptor (loop-only: owns 0x40351000 with –usbhs-loop).
Definition at line 962 of file board_periph_usbhs_host.c.
Referenced by internal_usbhs_block_register().