|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
USBFS register + CFIFO model (see board_usb_internal.h). More...
#include <stdio.h>#include <string.h>#include "board_usb_internal.h"#include "ra8_elc_regs.h"#include "ra8_usb_regs.h"Go to the source code of this file.
Functions | |
| uint16_t | priv_usb_intsts0 (void) |
| INTSTS0 value the device reads: event bits OR computed fields. | |
| void | priv_usb_intsts0_set (uint8_t bit) |
| Set an INTSTS0 event bit in the shadow (host asserts it). | |
| void | priv_usb_raise_irq (uc_engine *uc) |
| Raise the device controller interrupt (USBFS_INT, or USBHS after a role swap). | |
| static uint8_t | internal_cfifo_pipe (void) |
| Currently-selected CFIFO pipe number (CFIFOSEL.CURPIPE[3:0]). | |
| static bool | internal_cfifo_is_in (void) |
| True when CFIFOSEL selects the IN direction (device writes / fills). | |
| static usb_in_buf_t * | internal_cfifo_in_buf (void) |
| The device-IN staging buffer CFIFOSEL currently points at. | |
| static usb_out_buf_t * | internal_cfifo_out_buf (void) |
| The device-OUT staging buffer CFIFOSEL currently points at. | |
| static uint16_t | internal_cfifo_dtln (void) |
| Bytes still available for the device to read on the selected OUT buf. | |
| static uint32_t | internal_cfifo_read_port (unsigned size) |
| Service a CFIFO data-port read: drain one unit (1..4 bytes) from the OUT buffer. | |
| static void | internal_cfifo_write_port (uint32_t value, unsigned size) |
| Service a CFIFO data-port write: append one unit (1..4 bytes) to the IN buffer. | |
| static void | internal_cfifoctr_write (uint16_t value) |
| Apply a CFIFOCTR write: BCLR clears the buffer, BVAL commits an IN. | |
| static uint16_t | internal_cfifoctr_read (void) |
| CFIFOCTR read value: FRDY always ready, DTLN = OUT bytes available. | |
| uint32_t | priv_usb_reg_read (uint64_t off, unsigned size) |
Read one device-controller register; off is the byte offset into the window. | |
| void | priv_usb_reg_write (uint64_t off, uint32_t value, unsigned size) |
Write one device-controller register; off is the byte offset into the window. | |
| uint64_t | board_usb_read (uc_engine *uc, uint64_t addr, unsigned size, bool *handled) |
| Dispatch an MMIO read inside the USBFS register window. | |
| 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. | |
USBFS register + CFIFO model (see board_usb_internal.h).
The 16-bit reflect-on-read register shadow, the INTSTS0 composition, the CFIFO port/CFIFOCTR staging model and the MMIO window entry points – moved verbatim out of board_usb.c.
Definition in file board_usb_dev.c.
| uint64_t board_usb_read | ( | uc_engine * | uc, |
| uint64_t | addr, | ||
| unsigned | size, | ||
| bool * | handled ) |
Dispatch an MMIO read inside the USBFS register window.
| [in,out] | uc | Unicorn engine (unused today; kept for symmetry). |
| [in] | addr | Absolute peripheral address being read. |
| [in] | size | Access width in bytes (1 / 2 / 4). |
| [out] | handled | True iff addr is inside the USBFS window. |
*handled is true, else 0. Dispatch an mmio read inside the usbfs register window; this step is contained within the board USB model and uses bounded caller or module-owned storage.
| value | The operation-specific board USB read value. |
Definition at line 282 of file board_usb_dev.c.
References board_usbhs_host_reg_read(), k_usb_base, k_usb_span, priv_usb_reg_read(), and s_roles_swapped.
Referenced by board_periph_read().
| 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.
| [in,out] | uc | Unicorn engine (unused today; kept for symmetry). |
| [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 addr is inside the USBFS window. |
Dispatch an mmio write inside the usbfs register window; this step is contained within the board USB model and uses bounded caller or module-owned storage.
Definition at line 297 of file board_usb_dev.c.
References board_usb_roles_swap(), board_usbhs_host_reg_write(), k_ra8_syscfg_bit_dcfm, k_ra8_usb_off_syscfg, k_usb_base, k_usb_span, priv_usb_reg_write(), s_external_host, and s_roles_swapped.
Referenced by board_periph_write().
|
static |
Bytes still available for the device to read on the selected OUT buf.
Bytes still available for the device to read on the selected out buf; this step is contained within the board USB dev model and uses bounded caller or module-owned storage.
| value | The operation-specific cfifo dtln value. |
Definition at line 115 of file board_usb_dev.c.
References internal_cfifo_is_in(), internal_cfifo_out_buf(), and RA8_INTERNAL.
Referenced by internal_cfifoctr_read().
|
static |
The device-IN staging buffer CFIFOSEL currently points at.
Definition at line 92 of file board_usb_dev.c.
References internal_cfifo_pipe(), k_usb_pipe_count, RA8_INTERNAL, and s_usb.
Referenced by internal_cfifo_write_port(), and internal_cfifoctr_write().
|
static |
True when CFIFOSEL selects the IN direction (device writes / fills).
True when cfifosel selects the in direction (device writes / fills); this step is contained within the board USB dev model and uses bounded caller or module-owned storage.
| true | The cfifo is in condition holds or completed successfully; false otherwise. |
Definition at line 85 of file board_usb_dev.c.
References internal_usb_word(), k_ra8_fifosel_isel, k_ra8_usb_off_cfifosel, RA8_INTERNAL, and s_usb.
Referenced by internal_cfifo_dtln(), and internal_cfifoctr_write().
|
static |
The device-OUT staging buffer CFIFOSEL currently points at.
Definition at line 99 of file board_usb_dev.c.
References internal_cfifo_pipe(), k_usb_pipe_count, RA8_INTERNAL, and s_usb.
Referenced by internal_cfifo_dtln(), internal_cfifo_read_port(), and internal_cfifoctr_write().
|
static |
Currently-selected CFIFO pipe number (CFIFOSEL.CURPIPE[3:0]).
Currently-selected cfifo pipe number (cfifosel.curpipe[3:0]); this step is contained within the board USB dev model and uses bounded caller or module-owned storage.
| value | The operation-specific cfifo pipe value. |
Definition at line 69 of file board_usb_dev.c.
References internal_usb_word(), k_ra8_fifosel_curpipe, k_ra8_usb_off_cfifosel, RA8_INTERNAL, and s_usb.
Referenced by internal_cfifo_in_buf(), and internal_cfifo_out_buf().
|
static |
Service a CFIFO data-port read: drain one unit (1..4 bytes) from the OUT buffer.
Service a cfifo data-port read: drain one unit (1..4 bytes) from the out buffer; this step is contained within the board USB dev model and uses bounded caller or module-owned storage.
| [in] | size | Size of the requested region or access in bytes. |
| value | The operation-specific cfifo read port value. |
Definition at line 135 of file board_usb_dev.c.
References internal_cfifo_out_buf(), k_usb_byte_bits, and RA8_INTERNAL.
Referenced by priv_usb_reg_read().
|
static |
Service a CFIFO data-port write: append one unit (1..4 bytes) to the IN buffer.
Service a cfifo data-port write: append one unit (1..4 bytes) to the in buffer; this step is contained within the board USB dev 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 156 of file board_usb_dev.c.
References internal_cfifo_in_buf(), k_usb_byte_bits, k_usb_byte_mask, and RA8_INTERNAL.
Referenced by priv_usb_reg_write().
|
static |
CFIFOCTR read value: FRDY always ready, DTLN = OUT bytes available.
Cfifoctr read value: frdy always ready, dtln = out bytes available; this step is contained within the board USB dev model and uses bounded caller or module-owned storage.
| value | The operation-specific cfifoctr read value. |
Definition at line 208 of file board_usb_dev.c.
References internal_cfifo_dtln(), k_ra8_fifoctr_dtln, k_ra8_fifoctr_frdy, and RA8_INTERNAL.
Referenced by priv_usb_reg_read().
|
static |
Apply a CFIFOCTR write: BCLR clears the buffer, BVAL commits an IN.
Apply a cfifoctr write: bclr clears the buffer, bval commits an in; this step is contained within the board USB dev model and uses bounded caller or module-owned storage.
| [in] | value | Register or payload value involved in the operation. |
Definition at line 174 of file board_usb_dev.c.
References internal_cfifo_in_buf(), internal_cfifo_is_in(), internal_cfifo_out_buf(), k_ra8_fifoctr_bclr, k_ra8_fifoctr_bval, RA8_INTERNAL, and usb_in_buf_t::valid.
Referenced by priv_usb_reg_write().
| uint16_t priv_usb_intsts0 | ( | void | ) |
INTSTS0 value the device reads: event bits OR computed fields.
INTSTS0 value the device reads: event bits OR computed fields (dev).
Definition at line 23 of file board_usb_dev.c.
References internal_usb_word(), k_ra8_int0_bit_bemp, k_ra8_int0_bit_brdy, k_ra8_int0_bit_ctrt, k_ra8_int0_bit_dvst, k_ra8_int0_bit_nrdy, k_ra8_int0_bit_vbse, k_ra8_intsts0_mask_ctsq, k_ra8_intsts0_mask_dvsq, k_ra8_intsts0_mask_valid, k_ra8_intsts0_mask_vbsts, k_ra8_usb_off_intsts0, and s_usb.
Referenced by priv_usb_reg_read().
| void priv_usb_intsts0_set | ( | uint8_t | bit | ) |
Set an INTSTS0 event bit in the shadow (host asserts it).
Set one INTSTS0 event bit in the register shadow (dev).
Definition at line 39 of file board_usb_dev.c.
References internal_usb_word(), k_ra8_usb_off_intsts0, and s_usb.
Referenced by board_usb_bridge_bulk_in_take(), board_usb_bridge_bulk_out(), board_usb_bridge_bus_reset(), board_usb_bridge_ctrl_status(), board_usb_loop_bulk_in_read(), board_usb_loop_bulk_out(), board_usb_loop_bus_reset(), board_usb_loop_ctrl_out(), board_usb_loop_setup(), board_usb_loop_status_out_zlp(), internal_host_echo_send_out(), internal_host_msc_send_cbw(), internal_host_msc_take_in(), internal_host_step_status(), priv_bridge_pump_device(), priv_host_apply_no_data(), priv_host_deliver_setup(), priv_host_echo_read_in(), priv_host_mark_configured(), priv_host_run_idle_phase(), and priv_host_run_reset_phase().
| void priv_usb_raise_irq | ( | uc_engine * | uc | ) |
Raise the device controller interrupt (USBFS_INT, or USBHS after a role swap).
Pend the device's ICU interrupt via the registered raiser (dev).
Definition at line 46 of file board_usb_dev.c.
References g_dev_irq_event, s_raise, and s_usb_irqs.
Referenced by board_usb_bridge_bulk_in_take(), board_usb_bridge_bulk_out(), board_usb_bridge_bus_reset(), board_usb_bridge_ctrl_status(), board_usb_loop_bulk_in_read(), board_usb_loop_bulk_out(), board_usb_loop_bus_reset(), board_usb_loop_ctrl_out(), board_usb_loop_setup(), board_usb_loop_status_out_zlp(), internal_host_echo_send_out(), internal_host_msc_send_cbw(), internal_host_msc_take_in(), internal_host_step_status(), priv_bridge_pump_device(), priv_host_apply_no_data(), priv_host_deliver_setup(), priv_host_echo_read_in(), priv_host_mark_configured(), priv_host_run_idle_phase(), and priv_host_run_reset_phase().
| uint32_t priv_usb_reg_read | ( | uint64_t | off, |
| unsigned | size ) |
Read one device-controller register; off is the byte offset into the window.
USBFS window register read dispatch (dev).
Definition at line 215 of file board_usb_dev.c.
References internal_cfifo_read_port(), internal_cfifoctr_read(), internal_usb_word(), k_ra8_dvsq_powered, k_ra8_usb_off_cfifo, k_ra8_usb_off_cfifoctr, k_ra8_usb_off_dvstctr0, k_ra8_usb_off_frmnum, k_ra8_usb_off_intsts0, k_ra8_usb_off_syssts0, k_usb_cfifo_h, k_usb_cfifo_hh, k_usb_rhst_fs, priv_usb_intsts0(), and s_usb.
Referenced by board_usb_dev_reg_read(), and board_usb_read().
| void priv_usb_reg_write | ( | uint64_t | off, |
| uint32_t | value, | ||
| unsigned | size ) |
Write one device-controller register; off is the byte offset into the window.
USBFS window register write dispatch (dev).
Definition at line 253 of file board_usb_dev.c.
References internal_cfifo_write_port(), internal_cfifoctr_write(), internal_usb_word(), k_ra8_intsts0_mask_valid, k_ra8_usb_off_cfifo, k_ra8_usb_off_cfifoctr, k_ra8_usb_off_intsts0, k_usb_cfifo_h, k_usb_cfifo_hh, and s_usb.
Referenced by board_usb_dev_reg_write(), and board_usb_write().