Functions | |
| uint8_t | SelfTest_SMPU (const stl_smpu_entry_t *entry) |
| Runs the functional self-test for the CPUSS SMPU: temporarily configures a spare SMPU slave struct over the supplied scratch word so the active protection context of the calling core is denied, attempts a denied write, recovers from the resulting BusFault, and verifies both the SysFault source and the data integrity of the scratch word. | |
| bool | SelfTest_SMPU_HandleBusFault (uint32_t *stack) |
BusFault dispatch entry for the application's BusFault_Handler trampoline. | |
| uint8_t SelfTest_SMPU | ( | const stl_smpu_entry_t * | entry | ) |
Runs the functional self-test for the CPUSS SMPU: temporarily configures a spare SMPU slave struct over the supplied scratch word so the active protection context of the calling core is denied, attempts a denied write, recovers from the resulting BusFault, and verifies both the SysFault source and the data integrity of the scratch word.
| entry | Pointer to stl_smpu_entry_t describing the scratch word under test, the spare SMPU slave struct, the fault structure, and the expected fault source. |
CFSR.BFSR signature (see SelfTest_SMPU_HandleBusFault), the expected CPUSS_MPU_VIO SysFault with DATA0 equal to testAddress, and the scratch word content is unchanged. expectedValue on entry, the SMPU configuration failed, the expected fault was not observed, the scratch word content changed during the test, or a fault was already latched when the function was called (captured in faultStruct, or expectedFault pending): the write is then not attempted and the fault is left in faultStruct for the application. writeValue equal to expectedValue, expectedFault not a valid SysFault source, testAddress not aligned to SMPU_TEST_BLOCK_BYTES, smpuStruct already enabled, allowedPc out of range, or allowedPc equal to the active protection context. Nothing is written in this case.BusFault_Handler trampoline that calls SelfTest_SMPU_HandleBusFault() with the exception stack-frame pointer and falls back to the application's normal BusFault policy when the STL declines the fault (see the module note in SMPU (CPUSS shared memory protection STL module)).CTL, the interrupt mask and MASK0..2 are overwritten so that only stl_smpu_entry_t::expectedFault is captured, with the fault interrupt, reset request, fault_out and trigger outputs disabled. Any prior application configuration of that fault structure is lost.SCB->SHCSR.BUSFAULTENA is forced on for the duration of the call (its prior state is saved and restored on exit) so the denied access reports as a BusFault instead of escalating to HardFault.SCB->CFSR.BFSR bits (and so BFAR validity) left over from an earlier BusFault are cleared. MMFSR and UFSR are untouched.SCB->SHCSR.BUSFAULTENA is restored to its value on entry.MASK0..2 are left cleared; the application must set up its own fault policy after the self-test returns.BusFault_Handler stays installed; after this call returns, SelfTest_SMPU_HandleBusFault() returns false for any further BusFault so the application's normal policy runs.PRIMASK or FAULTMASK (for example inside __disable_irq() or Cy_SysLib_EnterCriticalSection()) and no BASEPRI at or above the BusFault priority. These conditions are not checked at runtime. If BusFault is masked, a precise fault escalates to HardFault. An imprecise fault stays pending: the function returns ERROR_STATUS and the pending BusFault is taken later, outside the test window, by the application's BusFault policy. Neither case can produce a false OK_STATUS.| bool SelfTest_SMPU_HandleBusFault | ( | uint32_t * | stack | ) |
BusFault dispatch entry for the application's BusFault_Handler trampoline.
Recovers the deliberate denied write driven by SelfTest_SMPU (rewrites the stacked PC to the STL resume point) and returns true.
A fault is accepted as the deliberate one only if all of the following are true:
STR up to the resume point), andCFSR.BFSR is exactly IMPRECISERR, or exactly PRECISERR | BFARVALID with the stacked PC at the STR and BFAR equal to stl_smpu_entry_t::testAddress.Any other BusFault, inside or outside the test window, is left untouched and false is returned so the application's normal policy handles it.
| stack | Pointer to the exception stack frame (r0, r1, r2, r3, r12, lr, pc, xpsr) that was active when the fault occurred, selected from MSP or PSP by the application trampoline. NULL is rejected (returns false). |
true - Fault was the STL's deliberate denied write; stack[6] has been rewritten to resume execution after the store and the accepted CFSR.BFSR bits have been cleared (other CFSR bits are preserved). The application trampoline must return normally so the exception return uses the (unchanged) EXC_RETURN value in LR. false - stack is NULL, or the fault does not match the criteria above. stack, SCB->CFSR, SCB->BFAR and the STL state are untouched. The application trampoline must invoke its own BusFault policy.