]> Joshua Wise's Git repositories - netwatch.git/blame - aseg/aseg.asm
Change the attrib register, remove the org 0x0 / shift it to org 0xA8000
[netwatch.git] / aseg / aseg.asm
CommitLineData
eee8da2e 1 org 0xA8000
f23390bf
JW
2[bits 16]
3entry:
4; mov al, 0x01 ; Say where we are.
5; out 0x80, al
6 mov ax, 0xA800
7 mov ds, ax ; Take us out of flat unreal mode, and
8 mov es, ax ; put us in true real mode.
9 mov fs, ax
10 mov gs, ax
11 mov ss, ax
eee8da2e 12 jmp 0xA800:(entry2-0xA8000) ; Long jump to a correct cs.
f23390bf
JW
13entry2:
14; mov al, 0x02
15; out 0x80, al
eee8da2e 16 lgdt [(gdtr-0xA8000)] ; Set up a new GDT.
f23390bf
JW
17 mov eax, 0x1
18 mov cr0, eax ; ... and enter pmode!
19 mov al, 0x03 ; Say we got here.
20 out 0x80, al
eee8da2e 21 jmp long 0x10:continue ; Now longjmp into the new code.
f23390bf
JW
22[bits 32]
23continue:
24; mov al, 0x04 ; Now we're in protected mode.
25; out 0x80, al
26
27 mov ax, 0x08 ; Set up segment selectors.
28 mov ds, ax
29 mov es, ax
30 mov fs, ax
31 mov gs, ax
32 mov ss, ax
33 mov esp, 0x1fffffff
34
35; mov al, 0x05
36; out 0x80, al
37
eee8da2e 38 mov al, [cstat]
f23390bf
JW
39 add al, 1
40 out 0x80, al
eee8da2e 41 mov [cstat], al
f23390bf
JW
42
43 mov eax, 0x11223344
eee8da2e 44 mov dword [status], eax
f23390bf
JW
45
46 mov dx, 0xCF8 ; save off the old config value
47 in dword eax, dx
48 mov [esp-4], eax
49
50 mov eax, 0x80000070 ; load in smramc
51 out dx, eax
52 mov dx, 0xCFC
53 in byte al, dx
54 mov [esp-5], al
55 and al, 0xF3 ; Allow graphics access
56 or al, 0x08
57 out dx, al
58
59 xor eax, eax
60 mov dx, 0x3D4
61 in byte al, dx
62 mov [esp-6], al ; save off the old VGA command
63 mov al, 0xC
64 out dx, al
65 inc dx
66 in al, dx
67 mov ah, al
68 dec dx
69 mov al, 0xD
70 out dx, al
71 inc dx
72 in al, dx
73 shl eax, 1
74 add eax, 0xB8000 ; yay
75 mov byte [eax+0], '1'
eee8da2e 76 mov byte [eax+1], 0x1F
f23390bf 77 mov byte [eax+2], '5'
eee8da2e 78 mov byte [eax+3], 0x1F
f23390bf 79 mov byte [eax+4], '-'
eee8da2e 80 mov byte [eax+5], 0x1F
f23390bf 81 mov byte [eax+6], '4'
eee8da2e 82 mov byte [eax+7], 0x1F
f23390bf 83 mov byte [eax+8], '1'
eee8da2e 84 mov byte [eax+9], 0x1F
f23390bf 85 mov byte [eax+10], '2'
eee8da2e 86 mov byte [eax+11], 0x1F
f23390bf
JW
87
88 mov dx, 0x3D4
89 mov al, [esp-6]
90 out dx, al
91
92
93 mov dx, 0xCFC ; restore smramc
94 mov al, [esp-5]
95 out dx, al
96
97 mov dx, 0xCF8 ; restore the old config value
98 mov eax, [esp-4]
99 out dx, eax
100
101 mov al, 0x40 ; ack the periodic IRQ
102 mov dx, 0x834
103 out dx, al
104
105 mov dx, 0x830
106 in al, dx
107 or al, 0x02 ; now ack the SMI itself
108 and al, 0xBF
109 out dx, al
110 or al, 0x40
111 out dx, al
112
113 rsm ; and leave SMM
114
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
126TIMES 512-($-$$) DB 0
127status:
128 dd 0xAA55AA55
129cstat:
130 db 0x00
This page took 0.038844 seconds and 4 git commands to generate.