|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
JTAG / IEEE-1149.1 Boundary Scan TAP HAL implementation. More...
#include "ra8_bscan.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_bscan_regs.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_log.h"Go to the source code of this file.
Data Structures | |
| struct | ra8_bscan_state_t |
| Firmware-side TAP bookkeeping object. More... | |
Enumerations | |
| enum | ra8_bscan_clear_arg_t : uint32_t { k_ra8_bscan_clear_mask_none = 0U } |
| Allowed values for the mask argument of ra8_bscan_clear_status. More... | |
Functions | |
| static bool | internal_is_known_instruction (ra8_bscan_instr_t instr) |
| Validate that an instruction code is one of the named opcodes. | |
| ra8_err_t | ra8_bscan_init (void) |
| Initialise the firmware-side TAP bookkeeping object. | |
| ra8_err_t | ra8_bscan_deinit (void) |
| Tear down the bookkeeping object. | |
| ra8_err_t | ra8_bscan_get_idcode (uint32_t *out) |
| Get the chip's hardwired JTIDR device ID code. | |
| ra8_err_t | ra8_bscan_get_status (ra8_bscan_status_t *out) |
| Get a snapshot of the driver's TAP bookkeeping state. | |
| ra8_err_t | ra8_bscan_clear_status (uint32_t mask) |
| Clear the recorded last-instruction state (no hardware effect). | |
| ra8_err_t | ra8_bscan_set_instruction (ra8_bscan_instr_t instr) |
| Record the JTIR opcode the external fixture is currently driving. | |
Variables | |
| static const char * | s_tag = "BSCAN" |
| Log tag used by every ra8_log_* call in this driver. | |
| static ra8_bscan_state_t | s_bscan_state |
| Singleton bookkeeping state. | |
JTAG / IEEE-1149.1 Boundary Scan TAP HAL implementation.
Tracks the firmware-side view of the RA8D2 boundary-scan Test Access Port. The four TAP registers (JTIR, JTIDR, JTBPR, JTBSR) described in HUM Ch 50.2 (p 3258-3259) are not memory-mapped – they live behind the JTAG pin interface and are accessible only to an external manufacturing-test fixture. This driver therefore carries no register accesses; it only maintains a small cached status object that other firmware modules can query.
Citation strategy: every public API includes at least one HUM Ch 50 citation in a comment to anchor the design intent in the spec, even though no register write actually happens.
Definition in file ra8_bscan.c.
| enum ra8_bscan_clear_arg_t : uint32_t |
Allowed values for the mask argument of ra8_bscan_clear_status.
Sibling drivers (ACMPHS, GLCDC, ...) accept a 32-bit bitmask of status flags to clear. This driver has no hardware flags so the only legal value is zero. The enum makes that contract explicit.
| Enumerator | |
|---|---|
| k_ra8_bscan_clear_mask_none | No-op mask – the only legal value. |
Definition at line 51 of file ra8_bscan.c.
|
static |
Validate that an instruction code is one of the named opcodes.
| [in] | instr | Candidate opcode. |
See implementation.
| k_ra8_ok | Operation succeeded. |
Definition at line 94 of file ra8_bscan.c.
References k_ra8_bscan_instr_bypass, k_ra8_bscan_instr_clamp, k_ra8_bscan_instr_extest, k_ra8_bscan_instr_highz, k_ra8_bscan_instr_idcode, k_ra8_bscan_instr_sample_preload, and RA8_INTERNAL.
Referenced by ra8_bscan_set_instruction().
|
nodiscard |
Clear the recorded last-instruction state (no hardware effect).
Resets the bookkeeping last_instruction field back to BYPASS (which is the TAP's reset-state instruction per HUM Ch 50.2.1, p 3258 – the JTIR reset value 0xE selects the BYPASS path). Used by the host-side fixture when it has finished a scan run and wants the firmware-side log to stop reporting the previous opcode.
| [in] | mask | Reserved – must be 0. Present to match the ra8_<short>_clear_status(uint32_t) shape used by sibling HAL drivers. |
| k_ra8_ok | Success. |
| k_ra8_err_invalid_arg | mask is non-zero. |
| k_ra8_err_not_initialized | ra8_bscan_init not called. |
Definition at line 159 of file ra8_bscan.c.
References k_ra8_bscan_clear_mask_none, k_ra8_bscan_instr_bypass, k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_ok, and s_bscan_state.
Referenced by bs_run_checks().
|
nodiscard |
Tear down the bookkeeping object.
Clears the recorded instruction and idcode and marks the driver as uninitialized. Touches no hardware.
| k_ra8_ok | Always succeeds. |
Definition at line 122 of file ra8_bscan.c.
References k_ra8_bscan_instr_bypass, k_ra8_ok, and s_bscan_state.
|
nodiscard |
Get the chip's hardwired JTIDR device ID code.
Returns the constant value the external fixture should observe when it shifts JTIDR out over TDO after issuing the IDCODE instruction (per HUM Ch 50.3.2 (4) IDCODE description, p 3261). The value is sourced from the regs header and does NOT require hardware access.
| [out] | out | Receives the 32-bit JTIDR value. |
| k_ra8_ok | Success, *out is valid. |
| k_ra8_err_null_ptr | out is NULL. |
| k_ra8_err_not_initialized | ra8_bscan_init has not been called. |
Definition at line 134 of file ra8_bscan.c.
References k_ra8_err_not_initialized, k_ra8_ok, RA8_CHECK_NULL_PTR, s_bscan_state, and s_tag.
Referenced by bs_run_checks().
|
nodiscard |
Get a snapshot of the driver's TAP bookkeeping state.
Returns the firmware-side view (initialized flag, last reported JTIR opcode, expected JTIDR). Does not query hardware – the four TAP registers (JTIR / JTIDR / JTBPR / JTBSR) are not CPU-readable (HUM Ch 50.2.3 explicit note, p 3259).
| [out] | out | Receives the status snapshot. |
| k_ra8_ok | Success. |
| k_ra8_err_null_ptr | out is NULL. |
Definition at line 147 of file ra8_bscan.c.
References ra8_bscan_status_t::expected_idcode, ra8_bscan_status_t::initialized, k_ra8_ok, ra8_bscan_status_t::last_instruction, RA8_CHECK_NULL_PTR, s_bscan_state, and s_tag.
Referenced by bs_run_checks().
|
nodiscard |
Initialise the firmware-side TAP bookkeeping object.
Marks the driver as initialized and seeds the expected JTIDR with the chip's hardwired device ID code (0x085D_A447, HUM Ch 50.2.2 Table 50.3 entry, p 3258). Touches no hardware: the boundary-scan TAP is reachable only over the external JTAG pins.
| k_ra8_ok | Always succeeds. |
Definition at line 110 of file ra8_bscan.c.
References k_ra8_bscan_instr_bypass, k_ra8_bscan_jtidr_reset, k_ra8_ok, ra8_log_info, s_bscan_state, and s_tag.
Referenced by bs_run_checks().
|
nodiscard |
Record the JTIR opcode the external fixture is currently driving.
Pure firmware-side bookkeeping. The opcode is validated against the named instruction set in HUM Ch 50.2.1 Table (p 3258); reserved 4-bit codes are rejected. The TAP itself does not see this call – the actual JTIR load happens via Shift-IR on the JTAG pins from the external fixture.
| [in] | instr | One of the named opcodes in ra8_bscan_instr_t. |
| k_ra8_ok | Recorded. |
| k_ra8_err_invalid_arg | instr is a reserved opcode. |
| k_ra8_err_not_initialized | ra8_bscan_init not called. |
Definition at line 174 of file ra8_bscan.c.
References internal_is_known_instruction(), k_ra8_err_invalid_arg, k_ra8_err_not_initialized, k_ra8_ok, ra8_log_info_val, s_bscan_state, and s_tag.
Referenced by bs_run_checks().
|
static |
Singleton bookkeeping state.
Updated only by this file.
Definition at line 72 of file ra8_bscan.c.
Referenced by ra8_bscan_clear_status(), ra8_bscan_deinit(), ra8_bscan_get_idcode(), ra8_bscan_get_status(), ra8_bscan_init(), and ra8_bscan_set_instruction().
|
static |
Log tag used by every ra8_log_* call in this driver.
Definition at line 39 of file ra8_bscan.c.