]> Joshua Wise's Git repositories - netwatch.git/blame - aseg/aseg.asm
OK, I guess both of them.
[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 76
f23390bf
JW
77 mov dx, 0xCFC ; restore smramc
78 mov al, [esp-5]
79 out dx, al
80
015cd976 81 mov dx, 0xCF8 ; restore the old PCI config value
f23390bf
JW
82 mov eax, [esp-4]
83 out dx, eax
84
015cd976
JW
85 mov al, [needclear]
86 cmp al, 0
87 jz noclear
88 mov al, 0 ; clear BSS
89 mov edi, [dataptr+4]
90 mov ecx, [dataptr+8]
91 rep stosb
92 mov [needclear], al
93
94noclear:
95 mov eax, [dataptr+12] ; jump into C
96 call eax
97
f23390bf
JW
98 mov al, 0x40 ; ack the periodic IRQ
99 mov dx, 0x834
100 out dx, al
101
015cd976 102 mov dx, 0x830 ; now ack the SMI itself
f23390bf 103 in al, dx
015cd976 104 or al, 0x02
f23390bf
JW
105 and al, 0xBF
106 out dx, al
107 or al, 0x40
108 out dx, al
109
110 rsm ; and leave SMM
111
015cd976
JW
112needclear:
113 db 0x01
114
f23390bf
JW
115 align 0x4
116gdtr:
117 db 0x27, 0x00
eee8da2e 118 dd gdt
f23390bf
JW
119 align 0x4
120gdt:
121 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
122 db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x93, 0xCF, 0x00 ; data segment
123 db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9B, 0xCF, 0x00 ; code segment
124 db 0xFF, 0xFF, 0x00, 0x80, 0x0A, 0x9B, 0xCF, 0x00 ; code segment for trampoline
125
f23390bf
JW
126cstat:
127 db 0x00
4bea7daf
JW
128
129TIMES 512-($-$$) DB 0
130dataptr:
131 ; 4 bytes of stack top
132 ; 4 bytes of BSS start
133 ; 4 bytes of BSS length
134 ; 4 bytes of C entry point
This page took 0.034826 seconds and 4 git commands to generate.