// Copyright (C) 2024 Clyne Sullivan // // Distributed under the GNU GPL v3 or later. You should have received a copy of // the GNU General Public License along with this program. // If not, see . extern const init_vector_table: [2]u32; const vector_table_type = [128] *const fn () void; // up to 256 var vector_table: vector_table_type align(256) = undefined; var vtor: **volatile vector_table_type = @ptrFromInt(0xE000ED08); pub const vector = enum(u7) { NMI = 2, HardFault, MemManage, BusFault, UsageFault, rsvd7, rsvd8, rsvd9, rsvd10, SVCall, DebugMonitor, rsvd13, PendSV, SysTick, }; pub fn initialize() void { vector_table[0] = @ptrFromInt(init_vector_table[0]); vector_table[1] = @ptrFromInt(init_vector_table[1]); register(.NMI, nmi); register(.HardFault, hardfault); register(.MemManage, memmanage); register(.BusFault, busfault); register(.UsageFault, usagefault); vtor.* = &vector_table; } pub fn register(index: vector, handler: *const fn () void) void { vector_table[@intFromEnum(index)] = handler; } fn nmi() void { while (true) {} } fn hardfault() void { while (true) {} } fn memmanage() void { while (true) {} } fn busfault() void { while (true) {} } fn usagefault() void { while (true) {} }