]> Joshua Wise's Git repositories - netwatch.git/blame - aseg/aseg.asm
Load into SMRAM, not just video RAM.
[netwatch.git] / aseg / aseg.asm
CommitLineData
eee8da2e 1 org 0xA8000
f23390bf
JW
2[bits 16]
3entry:
1458b275
JW
4 mov ax, 0xA800 ; Take us out of flat unreal mode,
5 mov ds, ax ; and put us in true real mode.
6 mov es, ax
f23390bf
JW
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
1458b275 24 mov esp, [dataptr] ; Load stack pointer.
f23390bf 25
1458b275
JW
26 mov al, [needclear] ; Has the aseg been run before?
27 cmp al, 0 ; If so,
28 jz noclear ; don't clear BSS.
29 mov al, 0 ; Otherwise, clear BSS.
015cd976
JW
30 mov edi, [dataptr+4]
31 mov ecx, [dataptr+8]
32 rep stosb
33 mov [needclear], al
34
35noclear:
1458b275
JW
36 mov eax, [dataptr+12] ; Load target jump address
37 call eax ; then jump into C.
015cd976 38
f23390bf
JW
39 rsm ; and leave SMM
40
41 align 0x4
42gdtr:
9b8c947b 43 db 0x17, 0x00
eee8da2e 44 dd gdt
f23390bf
JW
45 align 0x4
46gdt:
1458b275 47 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; initial null entry
f23390bf
JW
48 db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x93, 0xCF, 0x00 ; data segment
49 db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9B, 0xCF, 0x00 ; code segment
f23390bf 50
035d7af7
JW
51needclear:
52 db 0x01
4bea7daf 53
4bea7daf
JW
54dataptr:
55 ; 4 bytes of stack top
56 ; 4 bytes of BSS start
57 ; 4 bytes of BSS length
035d7af7
JW
58 ; 4 bytes of C entry point
59 ; These show up
This page took 0.033553 seconds and 4 git commands to generate.