* add p cc
[mascara-docs.git] / amd64 / bareMetalOS-0.5.2 / pure64.boot0 / src / interrupt.asm
blob4f910b994bdb1ca6ead74fc9ebe46b0c5518bf6a
1 ; =============================================================================
2 ; Pure64 -- a 64-bit OS loader written in Assembly for x86-64 systems
3 ; Copyright (C) 2008-2011 Return Infinity -- see LICENSE.TXT
5 ; Interrupts
6 ; =============================================================================
9 ; -----------------------------------------------------------------------------
10 ; Default exception handler
11 exception_gate:
12 mov rsi, int_string
13 call os_print_string
14 mov rsi, exc_string
15 call os_print_string
16 jmp $ ; hang
17 ; -----------------------------------------------------------------------------
20 ; -----------------------------------------------------------------------------
21 ; Default interrupt handler
22 interrupt_gate: ; handler for all other interrupts
23 iretq
24 ; -----------------------------------------------------------------------------
27 ; -----------------------------------------------------------------------------
28 ; Real-time clock interrupt. IRQ 0x00, INT 0x20
29 align 16
30 timer:
31 add qword [os_Counter], 1 ; 64-bit counter started at bootup
32 mov al, 0x20 ; Acknowledge the IRQ
33 out 0x20, al
34 iretq
35 ; -----------------------------------------------------------------------------
38 ; -----------------------------------------------------------------------------
39 ; CPU Exception Gates
40 exception_gate_00:
41 mov al, 0x00
42 jmp exception_gate_main
44 exception_gate_01:
45 mov al, 0x01
46 jmp exception_gate_main
48 exception_gate_02:
49 mov al, 0x02
50 jmp exception_gate_main
52 exception_gate_03:
53 mov al, 0x03
54 jmp exception_gate_main
56 exception_gate_04:
57 mov al, 0x04
58 jmp exception_gate_main
60 exception_gate_05:
61 mov al, 0x05
62 jmp exception_gate_main
64 exception_gate_06:
65 mov al, 0x06
66 jmp exception_gate_main
68 exception_gate_07:
69 mov al, 0x07
70 jmp exception_gate_main
72 exception_gate_08:
73 mov al, 0x08
74 jmp exception_gate_main
76 exception_gate_09:
77 mov al, 0x09
78 jmp exception_gate_main
80 exception_gate_10:
81 mov al, 0x0A
82 jmp exception_gate_main
84 exception_gate_11:
85 mov al, 0x0B
86 jmp exception_gate_main
88 exception_gate_12:
89 mov al, 0x0C
90 jmp exception_gate_main
92 exception_gate_13:
93 mov al, 0x0D
94 jmp exception_gate_main
96 exception_gate_14:
97 mov al, 0x0E
98 jmp exception_gate_main
100 exception_gate_15:
101 mov al, 0x0F
102 jmp exception_gate_main
104 exception_gate_16:
105 mov al, 0x10
106 jmp exception_gate_main
108 exception_gate_17:
109 mov al, 0x11
110 jmp exception_gate_main
112 exception_gate_18:
113 mov al, 0x12
114 jmp exception_gate_main
116 exception_gate_19:
117 mov al, 0x13
118 jmp exception_gate_main
120 exception_gate_main:
121 call os_print_newline
122 mov rsi, int_string
123 call os_print_string
124 mov rsi, exc_string00
125 and rax, 0xFF ; Clear out everything in RAX except for AL
126 mov bl, 8
127 mul bl ; AX = AL x BL
128 add rsi, rax ; Use the value in RAX as an offset to get to the right message
129 call os_print_string
130 call os_print_newline
131 call os_dump_regs
133 exception_gate_main_hang:
135 jmp exception_gate_main_hang ; Hang. User must reset machine at this point
137 ; Strings for the error messages
138 int_string db 'Pure64 - Interrupt ', 0
139 exc_string db '?? - Unknown Fatal Exception!', 0
140 align 16
141 exc_string00 db '00 - DE', 0
142 exc_string01 db '01 - DB', 0
143 exc_string02 db '02 ', 0
144 exc_string03 db '03 - BP', 0
145 exc_string04 db '04 - OF', 0
146 exc_string05 db '05 - BR', 0
147 exc_string06 db '06 - UD', 0
148 exc_string07 db '07 - NM', 0
149 exc_string08 db '08 - DF', 0
150 exc_string09 db '09 ', 0 ; No longer generated on new CPU's
151 exc_string10 db '10 - TS', 0
152 exc_string11 db '11 - NP', 0
153 exc_string12 db '12 - SS', 0
154 exc_string13 db '13 - GP', 0
155 exc_string14 db '14 - PF', 0
156 exc_string15 db '15 ', 0
157 exc_string16 db '16 - MF', 0
158 exc_string17 db '17 - AC', 0
159 exc_string18 db '18 - MC', 0
160 exc_string19 db '19 - XM', 0
163 ; =============================================================================
164 ; EOF