x86_64: replace comptime loop by GAS wrapper

This commit is contained in:
Quinten Kock 2021-01-30 22:08:38 +01:00
parent 0d10e698da
commit 062917d75b
1 changed files with 15 additions and 14 deletions

View File

@ -5,20 +5,21 @@ const c_idt = @cImport(@cInclude("arch/x86_64/idt.h"));
export const int_msg = "INTERRUPTED!\n"; export const int_msg = "INTERRUPTED!\n";
comptime { comptime {
@setEvalBranchQuota(2560000); asm(
comptime var i = 0; \\.macro isr_wrapperX number
var buf: [512]u8 = undefined; \\ isr_wrapper\number:
inline while (i < 256) : (i += 1) { \\ mov $\number, %rdi
const code = std.fmt.bufPrint(buf[0..512],
\\.global isr_wrapper{}
\\.type isr_wrapper{}, @function
\\isr_wrapper{}:
\\ mov ${}, %rdi
\\ call interrupt_handler \\ call interrupt_handler
\\ iretq \\ iretq
, .{i,i,i,i}) catch unreachable; \\.endm
asm (code); \\
} \\.altmacro
\\.set i,0
\\.rept 256
\\ isr_wrapperX %i
\\ .set i,i+1
\\.endr
);
} }
export fn interrupt_handler(int_type: u64) void { export fn interrupt_handler(int_type: u64) void {