]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - aseg/aseg.asm
Merge nyus.joshuawise.com:/storage/git/netwatch
[netwatch.git] / aseg / aseg.asm
... / ...
CommitLineData
1 org 0xA8000
2[bits 16]
3entry:
4 mov ax, 0xA800
5 mov ds, ax ; Take us out of flat unreal mode, and
6 mov es, ax ; put us in true real mode.
7 mov fs, ax
8 mov gs, ax
9 mov ss, ax
10 jmp 0xA800:(entry2-0xA8000) ; Long jump to a correct cs.
11entry2:
12 lgdt [(gdtr-0xA8000)] ; Set up a new GDT.
13 mov eax, 0x1
14 mov cr0, eax ; ... and enter pmode!
15 jmp long 0x10:continue ; Now longjmp into the new code.
16[bits 32]
17continue:
18 mov ax, 0x08 ; Set up segment selectors.
19 mov ds, ax
20 mov es, ax
21 mov fs, ax
22 mov gs, ax
23 mov ss, ax
24 mov esp, [dataptr]
25
26; mov al, [cstat]
27; add al, 1
28; out 0x80, al
29; mov [cstat], al
30
31 mov dx, 0xCF8 ; save off the old config value
32 in dword eax, dx
33 mov [esp-4], eax
34
35 mov eax, 0x80000070 ; load in smramc
36 out dx, eax
37 mov dx, 0xCFC
38 in byte al, dx
39 mov [esp-5], al
40 and al, 0xF3 ; Allow graphics access
41 or al, 0x08
42 out dx, al
43
44 xor eax, eax
45 mov dx, 0x3D4
46 in byte al, dx
47 mov [esp-6], al ; save off the old VGA command
48 mov al, 0xC
49 out dx, al
50 inc dx
51 in al, dx
52 mov ah, al
53 dec dx
54 mov al, 0xD
55 out dx, al
56 inc dx
57 in al, dx
58 shl eax, 1
59 add eax, 0xB8000 ; yay
60 mov byte [eax+0], '1'
61 mov byte [eax+1], 0x1F
62 mov byte [eax+2], '5'
63 mov byte [eax+3], 0x1F
64 mov byte [eax+4], '-'
65 mov byte [eax+5], 0x1F
66 mov byte [eax+6], '4'
67 mov byte [eax+7], 0x1F
68 mov byte [eax+8], '1'
69 mov byte [eax+9], 0x1F
70 mov byte [eax+10], '2'
71 mov byte [eax+11], 0x1F
72
73 mov dx, 0x3D4 ; restore the old stuff
74 mov al, [esp-6]
75 out dx, al
76
77 mov al, 0
78 mov edi, [dataptr+4] ; clear BSS
79 mov ecx, [dataptr+8]
80 rep stosb
81
82 mov dx, 0xCFC ; restore smramc
83 mov al, [esp-5]
84 out dx, al
85
86 mov eax, [dataptr+12]
87 call eax
88
89 mov dx, 0xCF8 ; restore the old config value
90 mov eax, [esp-4]
91 out dx, eax
92
93 mov al, 0x40 ; ack the periodic IRQ
94 mov dx, 0x834
95 out dx, al
96
97 mov dx, 0x830
98 in al, dx
99 or al, 0x02 ; now ack the SMI itself
100 and al, 0xBF
101 out dx, al
102 or al, 0x40
103 out dx, al
104
105 rsm ; and leave SMM
106
107 align 0x4
108gdtr:
109 db 0x27, 0x00
110 dd gdt
111 align 0x4
112gdt:
113 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
114 db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x93, 0xCF, 0x00 ; data segment
115 db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9B, 0xCF, 0x00 ; code segment
116 db 0xFF, 0xFF, 0x00, 0x80, 0x0A, 0x9B, 0xCF, 0x00 ; code segment for trampoline
117
118cstat:
119 db 0x00
120
121TIMES 512-($-$$) DB 0
122dataptr:
123 ; 4 bytes of stack top
124 ; 4 bytes of BSS start
125 ; 4 bytes of BSS length
126 ; 4 bytes of C entry point
This page took 0.02596 seconds and 4 git commands to generate.