-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_kernel.asm
114 lines (89 loc) · 2.28 KB
/
init_kernel.asm
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
%define video_mem 0xFA000
%define base_code_segment 0x10
;Constantes de selector de TSS
%define print_tsd 0x18
;extern GDT_DESC
extern tsss;
;extern gdt;
BITS 16
global start
start:
;incluir en el linkeo
mov ax, 0h
mov es, ax
mov ds, ax
call disable_A20
;xchg bx, bx
call check_A20
;xchg bx, bx
call enable_A20
;xchg bx, bx
call check_A20
;xchg bx, bx
cli
mov cx, gdt_len
mov di, 0000H
mov si, gdt
rep movsb
mov ax , [gdt_len]
mov word [es:7C00h] , ax
mov word [es:7c02h] , 0
mov word [es:7c04h] , 0
lgdt [gdt_desc]
mov eax, cr0
or ax, 0x1
mov cr0,eax
jmp base_code_segment:inicio_32
;/////////////////////////////////////////////
;//////////// Arranco Modo protegido.
;/////////////////////////////////////////////
BITS 32
inicio_32:
; iniciar segmentos
mov ax, 8h
mov es, ax
mov ss, ax
mov ds, ax
;/////////////////////////////////////////////
;//////////// Arranco Paginación: ( . ) ( . )
;/////////////////////////////////////////////
;Modifico CR3 para pasar a paginación.
MOV eax, PD
mov CR3, eax
MOV ebx, CR0
OR ebx, 0x80000000
MOV CR0, ebx
jmp base_code_segment:pagination_success
pagination_success:
;////////////////////////////////////////////////
;//////////////// WELCOME TO PAGINATION
;////////////////////////////////////////////////
;//////////////////////////////////////////////////////
;////////////////// Enableing interruptions
;//////////////////////////////////////////////////////
;Muevo los IRQ0 - IRQ7 de pic N1 a las interrupciones del 32 al 48
mov BH, 0x20
mov BL, 0x28
call ReprogramarPICs
;Habilito timer tick
mov al,0h
out 21h,al
LIDT [idt_desc]
STI
;//////////////////////////////////////////////////////
;////////////////// CAll to print using TSS
;//////////////////////////////////////////////////////
mov eax, $tsss ;Load selector de Tarea base
LTR ax
call print_tsd:0x0
fake_tsd_call:
jmp $ ; colgamos el programa
%include "exceptions.asm"
%include "hw0.asm"
%include "includes/estructuras_paginacion.inc"
%include "includes/estructuras_idt.inc"
%include "includes/estructuras_gdt.inc"
%include "tasks.asm"
%include "includes/estructuras_tss.inc"
%include "includes/a20.asm"
%include "includes/macrosmodoreal.mac"