summaryrefslogtreecommitdiff
path: root/stage3/isr.lua
blob: 83515a529e5685d6b9186488af0975eae5945015 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
print("global idt_entries")
print("extern interrupt_handler")

local has_error_code = {}
for _, x in pairs({8, 10, 11, 12, 13, 14, 17, 21, 29, 30}) do
	has_error_code[x] = true
end

for i = 0, 255 do
	print("isr_" .. i .. ":")
	print("cli")

	if not has_error_code[i] then
		print("push 0")
	end

	print("push " .. i)
	print("jmp isr_common")
end

print("idt_entries:")
for i = 0, 255 do
	print("dq isr_"..i)
end

print([[
isr_common:
	push   r11
	push   r10
	push   r9
	push   r8
	push   rdi
	push   rsi
	push   rcx
	push   rdx
	push   rax

	cld
	mov rdi, rsp
	call interrupt_handler

	pop    rax
	pop    rdx
	pop    rcx
	pop    rsi
	pop    rdi
	pop    r8
	pop    r9
	pop    r10
	pop    r11

	add rsp, 16

	iretq
]])