-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_isr_wrapper.py
executable file
·42 lines (33 loc) · 1015 Bytes
/
gen_isr_wrapper.py
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
#!/usr/bin/python3
print("/*this file is automatically generated by gen_isr_wrapper.py*/")
print(".code64")
print(".section .text")
for i in range(0, 256):
print(".globl _isr" + str(i))
print(".align 16")
print()
print()
print()
have_error = [8, 10, 11, 12, 13, 14] #intel 6.15 interrupt with exseption error code
for i in range(0, 256):
print("_isr" + str(i) + ":")
if i not in have_error:
print(" push $0")
print(" push $" + str(i))
print(" jmp isr_wrapper")
print()
#http://www.x86-64.org/documentation/abi.pdf
#page 21, not save register
reg = ["rax", "rcx", "rdx", "rsi", "rdi" ,"r8", "r9", "r10", "r11"]
#interrupt controler
print("isr_wrapper:")
for cur_reg in reg[::-1]:
print(" push %" + cur_reg) #push registers on stack
print()
print(" call interrupt_handler")
print()
for cur_reg in reg:
print(" pop %" + cur_reg) #pop registers on stack
print()
print(" add $16, %rsp") #pop from stack error_code and id_interrupt
print(" iretq")