]> Joshua Wise's Git repositories - netwatch.git/blame - aseg/aseg.asm
aseg with a working C execution environment
[netwatch.git] / aseg / aseg.asm
CommitLineData
eee8da2e 1 org 0xA8000
f23390bf
JW
2[bits 16]
3entry:
f23390bf
JW
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
eee8da2e 10 jmp 0xA800:(entry2-0xA8000) ; Long jump to a correct cs.
f23390bf 11entry2:
eee8da2e 12 lgdt [(gdtr-0xA8000)] ; Set up a new GDT.
f23390bf
JW
13 mov eax, 0x1
14 mov cr0, eax ; ... and enter pmode!
eee8da2e 15 jmp long 0x10:continue ; Now longjmp into the new code.
f23390bf
JW
16[bits 32]
17continue:
f23390bf
JW
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
4bea7daf 24 mov esp, [dataptr]
f23390bf 25
4bea7daf
JW
26; mov al, [cstat]
27; add al, 1
f23390bf 28; out 0x80, al
4bea7daf 29; mov [cstat], al
f23390bf 30
f23390bf
JW
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'
eee8da2e 61 mov byte [eax+1], 0x1F
f23390bf 62 mov byte [eax+2], '5'
eee8da2e 63 mov byte [eax+3], 0x1F
f23390bf 64 mov byte [eax+4], '-'
eee8da2e 65 mov byte [eax+5], 0x1F
f23390bf 66 mov byte [eax+6], '4'
eee8da2e 67 mov byte [eax+7], 0x1F
f23390bf 68 mov byte [eax+8], '1'
eee8da2e 69 mov byte [eax+9], 0x1F
f23390bf 70 mov byte [eax+10], '2'
eee8da2e 71 mov byte [eax+11], 0x1F
f23390bf 72
4bea7daf 73 mov dx, 0x3D4 ; restore the old stuff
f23390bf
JW
74 mov al, [esp-6]
75 out dx, al
4bea7daf
JW
76
77 mov al, 0
78 mov edi, [dataptr+4] ; clear BSS
79 mov ecx, [dataptr+8]
80 rep stosb
f23390bf
JW
81
82 mov dx, 0xCFC ; restore smramc
83 mov al, [esp-5]
84 out dx, al
4bea7daf
JW
85
86 mov eax, [dataptr+12]
87 call eax
f23390bf
JW
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
eee8da2e 110 dd gdt
f23390bf
JW
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
f23390bf
JW
118cstat:
119 db 0x00
4bea7daf
JW
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.030237 seconds and 4 git commands to generate.