Skip to content

Commit 3633cb4

Browse files
authored
Merge pull request #90 from ReturnInfinity/nopic
Remove interrupts
2 parents 9b7a8d3 + 37fcc9b commit 3633cb4

6 files changed

Lines changed: 45 additions & 129 deletions

File tree

src/init/cpu.asm

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88

99
init_cpu:
1010

11-
; Disable Cache
11+
; Disable Cache
1212
mov rax, cr0
1313
btr rax, 29 ; Clear No Write Thru (Bit 29)
1414
bts rax, 30 ; Set Cache Disable (Bit 30)
1515
mov cr0, rax
1616

17-
; Flush Cache
17+
; Flush Cache
1818
wbinvd
1919

20-
; Flush TLB
20+
; Flush TLB
2121
mov rax, cr3
2222
mov cr3, rax
2323

@@ -108,35 +108,35 @@ init_cpu:
108108
; bts eax, 11 ; Set MTRR Enable (Bit 11), Only enables Variable Range MTRR's
109109
; wrmsr
110110

111-
; Flush TLB
111+
; Flush TLB
112112
mov rax, cr3
113113
mov cr3, rax
114114

115-
; Flush Cache
115+
; Flush Cache
116116
wbinvd
117117

118-
; Enable Cache
118+
; Enable Cache
119119
mov rax, cr0
120120
btr rax, 29 ; Clear No Write Thru (Bit 29)
121121
btr rax, 30 ; Clear CD (Bit 30)
122122
mov cr0, rax
123123

124-
; Enable Floating Point
124+
; Enable Floating Point
125125
mov rax, cr0
126126
bts rax, 1 ; Set Monitor co-processor (Bit 1)
127127
btr rax, 2 ; Clear Emulation (Bit 2)
128128
mov cr0, rax
129129

130-
; Enable SSE
130+
; Enable SSE
131131
mov rax, cr4
132132
bts rax, 9 ; Set Operating System Support for FXSAVE and FXSTOR instructions (Bit 9)
133133
bts rax, 10 ; Set Operating System Support for Unmasked SIMD Floating-Point Exceptions (Bit 10)
134134
mov cr4, rax
135135

136-
; Enable Math Co-processor
136+
; Enable Math Co-processor
137137
finit
138138

139-
; Enable AVX-1 and AVX-2
139+
; Enable AVX-1 and AVX-2
140140
mov eax, 1 ; CPUID Feature information 1
141141
cpuid ; Sets info in ECX and EDX
142142
bt ecx, 28 ; AVX-1 is supported if bit 28 is set in ECX
@@ -154,7 +154,7 @@ avx_supported:
154154
xsetbv ; Save XCR0 register
155155
avx_not_supported:
156156

157-
; Enable AVX-512
157+
; Enable AVX-512
158158
mov eax, 7 ; CPUID Feature information 7
159159
xor ecx, ecx ; Extended Features 0
160160
cpuid ; Sets info in EBX, ECX, and EDX

src/init/pic.asm

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/init/smp.asm

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,6 @@ noMP:
109109
div rcx
110110
mov [p_cpu_speed], ax
111111

112-
cli ; Disable Interrupts
113-
114-
; Disable PIT
115-
mov al, 0x30 ; Channel 0 (7:6), Access Mode lo/hi (5:4), Mode 0 (3:1), Binary (0)
116-
out 0x43, al
117-
mov al, 0x00
118-
out 0x40, al
119-
120112
ret
121113

122114

src/init/smp_ap.asm

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BITS 16
1010

1111
init_smp_ap:
1212

13-
; Enable the A20 gate
13+
; Enable the A20 gate
1414
set_A20_ap:
1515
in al, 0x64
1616
test al, 0x02
@@ -24,10 +24,10 @@ check_A20_ap:
2424
mov al, 0xDF
2525
out 0x60, al
2626

27-
; At this point we are done with real mode and BIOS interrupts. Jump to 32-bit mode.
28-
lgdt [cs:GDTR32] ; load GDT register
27+
; At this point we are done with real mode and BIOS interrupts. Jump to 32-bit mode.
28+
lgdt [cs:GDTR32] ; Load GDT register
2929

30-
mov eax, cr0 ; switch to 32-bit protected mode
30+
mov eax, cr0 ; Switch to 32-bit protected mode
3131
or al, 1
3232
mov cr0, eax
3333

@@ -41,7 +41,7 @@ align 16
4141
BITS 32
4242

4343
startap32:
44-
mov eax, 16 ; load 4 GB data descriptor
44+
mov eax, 16 ; Load 4 GB data descriptor
4545
mov ds, ax ; to all data segment registers
4646
mov es, ax
4747
mov fs, ax
@@ -56,30 +56,30 @@ startap32:
5656
xor ebp, ebp
5757
mov esp, 0x7000 ; Set a known free location for the temporary stack (shared by all APs)
5858

59-
; Load the GDT
59+
; Load the GDT
6060
lgdt [GDTR64]
6161

62-
; Enable extended properties
62+
; Enable extended properties
6363
mov eax, cr4
6464
or eax, 0x0000000B0 ; PGE (Bit 7), PAE (Bit 5), and PSE (Bit 4)
6565
mov cr4, eax
6666

67-
; Point cr3 at PML4
67+
; Point cr3 at PML4
6868
mov eax, 0x00002008 ; Write-thru (Bit 3)
6969
mov cr3, eax
7070

71-
; Enable long mode and SYSCALL/SYSRET
71+
; Enable long mode and SYSCALL/SYSRET
7272
mov ecx, 0xC0000080 ; EFER MSR number
7373
rdmsr ; Read EFER
7474
or eax, 0x00000101 ; LME (Bit 8)
7575
wrmsr ; Write EFER
7676

77-
; Enable paging to activate long mode
77+
; Enable paging to activate long mode
7878
mov eax, cr0
7979
or eax, 0x80000000 ; PG (Bit 31)
8080
mov cr0, eax
8181

82-
; Make the jump directly from 16-bit real mode to 64-bit long mode
82+
; Make the jump directly from 16-bit real mode to 64-bit long mode
8383
jmp SYS64_CODE_SEL:startap64
8484

8585
align 16
@@ -124,22 +124,13 @@ startap64:
124124
mov rsp, rax ; Pure64 leaves 0x50000-0x9FFFF free so we use that
125125

126126
lgdt [GDTR64] ; Load the GDT
127-
lidt [IDTR64] ; load IDT register
128-
129-
; Enable Local APIC on AP
130-
; mov rsi, [p_LocalAPICAddress]
131-
; add rsi, 0x00f0 ; Offset to Spurious Interrupt Register
132-
; mov rdi, rsi
133-
; lodsd
134-
; or eax, 0000000100000000b
135-
; stosd
127+
lidt [IDTR64] ; Load the IDT
136128

137129
call init_cpu ; Setup CPU
138130

139131
sti ; Activate interrupts for SMP
140132
jmp ap_sleep
141133

142-
143134
align 16
144135

145136
ap_sleep:

src/pure64.asm

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,28 @@ start64:
208208
out 0x21, al
209209
out 0xA1, al
210210

211+
; Initialize and remap PIC IRQ's
212+
; ICW1
213+
mov al, 0x11; ; Initialize PIC 1, init (bit 4) and ICW4 (bit 0)
214+
out 0x20, al
215+
mov al, 0x11; ; Initialize PIC 2, init (bit 4) and ICW4 (bit 0)
216+
out 0xA0, al
217+
; ICW2
218+
mov al, 0x20 ; IRQ 0-7: interrupts 20h-27h
219+
out 0x21, al
220+
mov al, 0x28 ; IRQ 8-15: interrupts 28h-2Fh
221+
out 0xA1, al
222+
; ICW3
223+
mov al, 4
224+
out 0x21, al
225+
mov al, 2
226+
out 0xA1, al
227+
; ICW4
228+
mov al, 1
229+
out 0x21, al
230+
mov al, 1
231+
out 0xA1, al
232+
211233
; Disable NMIs
212234
in al, 0x70
213235
or al, 0x80
@@ -723,12 +745,6 @@ pde_end:
723745
mov ebx, 4
724746
call debug_block
725747

726-
mov rsi, msg_pic
727-
call debug_msg
728-
call init_pic ; Configure the PIC(s), activate interrupts
729-
mov rsi, msg_ok
730-
call debug_msg
731-
732748
mov rsi, msg_smp
733749
call debug_msg
734750
call init_smp ; Init of SMP, deactivate interrupts
@@ -883,7 +899,6 @@ clear_regs:
883899

884900
%include "init/acpi.asm"
885901
%include "init/cpu.asm"
886-
%include "init/pic.asm"
887902
%include "init/serial.asm"
888903
%include "init/hpet.asm"
889904
%include "init/smp.asm"

src/sysvar.asm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ msg_bios: db 'bios', 0
1717
msg_uefi: db 'uefi', 0
1818
msg_acpi: db 13, 10, 'acpi ', 0
1919
msg_bsp: db 13, 10, 'bsp ', 0
20-
msg_pic: db 13, 10, 'pic ', 0
2120
msg_smp: db 13, 10, 'smp ', 0
2221
msg_kernel: db 13, 10, 'kernel start', 13, 10, 0
2322

0 commit comments

Comments
 (0)