Skip to content

Commit 66aba99

Browse files
- fix: M7 missing CFSR type
- add: missing FPU fault bits in CFSR
1 parent 3380d47 commit 66aba99

3 files changed

Lines changed: 26 additions & 9 deletions

File tree

core/src/cpus/cortex_m.zig

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -961,12 +961,14 @@ pub const debug = struct {
961961
context.return_address,
962962
context.xpsr,
963963
});
964-
logger.err(" instruction bus error = {}", .{bfsr.instruction_bus_error});
965-
logger.err(" precice data bus error = {}", .{bfsr.precice_data_bus_error});
966-
logger.err(" imprecice data bus error = {}", .{bfsr.imprecice_data_bus_error});
967-
logger.err(" unstacking exception error = {}", .{bfsr.unstacking_exception_error});
968-
logger.err(" exception stacking error = {}", .{bfsr.exception_stacking_error});
969-
logger.err(" busfault address register valid = {}", .{bfsr.busfault_address_register_valid});
964+
logger.err(" instruction bus error = {}", .{bfsr.instruction_bus_error});
965+
logger.err(" precice data bus error = {}", .{bfsr.precice_data_bus_error});
966+
logger.err(" imprecice data bus error = {}", .{bfsr.imprecice_data_bus_error});
967+
logger.err(" unstacking exception error = {}", .{bfsr.unstacking_exception_error});
968+
logger.err(" exception stacking error = {}", .{bfsr.exception_stacking_error});
969+
if (has_fpu)
970+
logger.err(" fpu lazy state preservation fault = {}", .{bfsr.fpu_lazy_state_preservation_fault});
971+
logger.err(" busfault address register valid = {}", .{bfsr.busfault_address_register_valid});
970972
if (bfsr.busfault_address_register_valid) {
971973
const address = peripherals.scb.BFAR;
972974
logger.err(" busfault address register = 0x{X:0>8}", .{address});

core/src/cpus/cortex_m/m7.zig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ pub const SystemControlBlock = extern struct {
9999
/// System Handler Contol and State Register
100100
SHCSR: mmio.Mmio(shared.scb.SHCSR),
101101
/// Configurable Fault Status Register
102-
CFSR: u32,
102+
CFSR: mmio.Mmio(packed struct(u32) {
103+
/// MemManage Fault Register.
104+
MMFSR: shared.scb.MMFSR,
105+
/// BusFault Status Register.
106+
BFSR: shared.scb.BFSR,
107+
/// Usage Fault Status Register.
108+
UFSR: shared.scb.UFSR,
109+
}),
103110
/// MemManage Fault Status Register
104111
MMSR: u32,
105112
/// BusFault Status Register

core/src/cpus/cortex_m/shared_types.zig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,12 @@ pub const scb = struct {
158158
/// When this bit is 1, the SP is still adjusted but the values in the context area on the stack might be incorrect. The processor has not written a fault address to the MMAR.
159159
MSTKERR: u1, // [4], RW
160160

161+
/// 0: No MemManage fault occurred during floating-point lazy state preservation.
162+
/// 1: A MemManage fault occurred during floating-point lazy state preservation.
163+
MLSPERR: u1, // [5], RW (FPU only)
164+
161165
/// Reserved.
162-
_reserved0: u2, // [6:5], RW
166+
_reserved0: u1, // [6], RW
163167

164168
/// MemManage Fault Address Register (MMFAR) valid flag:
165169
/// 0 = value in MMAR is not a valid fault address
@@ -202,8 +206,12 @@ pub const scb = struct {
202206
/// When the processor sets this bit to 1, the SP is still adjusted but the values in the context area on the stack might be incorrect. The processor does not write a fault address to the BFAR.
203207
exception_stacking_error: bool, // [4], RW
204208

209+
/// 0: No bus fault occurred during floating-point lazy state preservation.
210+
/// 1: A bus fault occurred during floating-point lazy state preservation.
211+
fpu_lazy_state_preservation_fault: bool, // [5], RW (FPU only)
212+
205213
/// Reserved.
206-
_reserved0: u2, // [6:5], RW
214+
_reserved0: u1, // [6], RW
207215

208216
/// BusFault Address Register (BFAR) valid flag:
209217
/// 0 = value in BFAR is not a valid fault address

0 commit comments

Comments
 (0)