On Mon, Mar 22, 2021 at 2:33 PM Joel Sherrill <j...@rtems.org> wrote: >> +static const char* _exception_class_to_string( uint16_t exception_class ) >> +{ >> + switch (exception_class) >> + { >> + case 0b000001: return "Trapped WFI or WFE instruction"; >> + case 0b000011: return "Trapped MCR or MRC access with (coproc==0b1111)"; >> + case 0b000100: return "Trapped MCRR or MRRC access with (coproc==0b1111)"; >> + case 0b000101: return "Trapped MCR or MRC access with (coproc==0b1110)"; >> + case 0b000110: return "Trapped LDC or STC access"; >> + case 0b001100: return "Trapped MRRC access with (coproc==0b1110)"; >> + case 0b001110: return "Illegal Execution state"; >> + case 0b011000: return "Trapped MSR, MRS, or System instruction"; >> + case 0b100000: return "Instruction Abort from a lower Exception level"; >> + case 0b100001: return "Instruction Abort taken without a change in >> Exception " >> + "level"; >> + case 0b100010: return "PC alignment fault"; >> + case 0b100100: return "Data Abort from a lower Exception level"; >> + case 0b100101: return "Data Abort taken without a change in Exception >> level"; >> + case 0b100110: return "SP alignment fault"; >> + case 0b110000: return "Breakpoint exception from a lower Exception level"; >> + case 0b110001: return "Breakpoint exception taken without a change in " >> + "Exception level"; >> + case 0b110010: return "Software Step exception from a lower Exception >> level"; >> + case 0b110011: return "Software Step exception taken without a change in " >> + "Exception level"; >> + case 0b110100: return "Watchpoint exception from a lower Exception level"; >> + case 0b110101: return "Watchpoint exception taken without a change in " >> + "Exception level"; >> + case 0b111000: return "BKPT instruction execution in AArch32 state"; >> + case 0b111100: return "BRK instruction execution in AArch64 state"; > > > Before someone else asks... > > (1) Are binary constants standard C? The stackover flow discussion I found > says they are a GNU extension which puts them off-limits.
No, it doesn't look like they are. Darn. I'll switch to hex. > (2). These appear to be 6 bits and there is nothing ensuring only those six > bits are set before the switch. Is there a chance other bits could be set > messing up this switch? Currently, no, there is no chance other bits could be set. This function is only called from one place, and the argument is bitwise AND-ed with 0x3f before being passed in. >> +static void _binary_sprintf( >> + char *s, >> + size_t maxlen, >> + uint32_t num_bits, >> + uint32_t value >> +) >> +{ >> + string_context sctx = { >> + .s = s, >> + .n = maxlen >> + }; >> + uint32_t mask = 1<<(num_bits-1); >> + int cx = 0; >> + >> + while ( mask != 0 ) { >> + cx += _IO_Printf(put_char, &sctx, "%d", (value & mask ? 1 : 0)); >> + //cx += snprintf(s + cx, maxlen - cx, "%d", (value&mask ? 1 : 0)); > > > Commented out. Will fix. Alex _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel