PatchworkOS
Loading...
Searching...
No Matches
interrupt.inc
Go to the documentation of this file.
1%pragma once
2
3; The size of a interrupt frame in bytes
4%define INTERRUPT_FRAME_SIZE 176
5
6; Will construct the registers section of a interrupt frame
7%macro INTERRUPT_FRAME_REGS_PUSH 0
8 push rax
9 push rbx
10 push rcx
11 push rdx
12 push rsi
13 push rdi
14 push rbp
15 push r8
16 push r9
17 push r10
18 push r11
19 push r12
20 push r13
21 push r14
22 push r15
23%endmacro
24
25; Will pop the registers section of a interrupt frame
26%macro INTERRUPT_FRAME_REGS_POP 0
27 pop r15
28 pop r14
29 pop r13
30 pop r12
31 pop r11
32 pop r10
33 pop r9
34 pop r8
35 pop rbp
36 pop rdi
37 pop rsi
38 pop rdx
39 pop rcx
40 pop rbx
41 pop rax
42%endmacro
43
44%macro INTERRUPT_FRAME_POP_AND_JUMP 0
45 INTERRUPT_FRAME_REGS_POP
46
47 add rsp, 16
48 iretq
49%endmacro
50
51; Constructs a interrupt frame from current cpu state
52%macro INTERRUPT_FRAME_CONSTRUCT 0
53 xor rax, rax ; Set to zero to prevent weirdness with the ss and cs registers.
54 mov r8, [rsp] ; Get the return address.
55 ; Store the stack pointer from before this function was called
56 mov r9, rsp
57 add r9, 8
58
59 ; Construct interrupt frame
60 mov ax, ss
61 push rax
62 push r9
63 pushfq
64 mov ax, cs
65 push rax
66 push r8
67
68 ; Ignore vector and error code.
69 push qword 0
70 push qword 0
71
72 INTERRUPT_FRAME_REGS_PUSH
73%endmacro
static uintptr_t address
Definition hpet.c:12
static pmm_stack_t stack
Definition pmm.c:36