]> Joshua Wise's Git repositories - netwatch.git/blob - aseg-paging/entry.asm
move packet to aseg-paging in preparation for aseg's deletion
[netwatch.git] / aseg-paging / entry.asm
1         org 0xA8000
2 [bits 16]
3 entry:
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
7         mov fs, ax
8         mov gs, ax
9         mov ss, ax
10         jmp 0xA800:(entry2-0xA8000)     ; Long jump to a correct cs.
11 entry2:
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]
17 continue:
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]              ; Load stack pointer.
25
26         ; Before we do anything, turn off alignment checking.
27         pushf
28         pop eax
29         and eax, ~(1 << 18)
30         push eax
31         popf
32         
33         mov eax, [dataptr+4]            ; Load target jump address
34         call eax                        ; then jump into C.
35
36         rsm                             ; and leave SMM
37
38         align 0x4
39 gdtr:
40         db 0x17, 0x00
41         dd gdt
42         align 0x4
43 gdt:
44         db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00       ; initial null entry
45         db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x93, 0xCF, 0x00       ; data segment
46         db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9B, 0xCF, 0x00       ; code segment
47
48
49 dataptr:
50         ; 4 bytes of stack top
51         ; 4 bytes of C entry point
52         ; These show up 
This page took 0.026445 seconds and 4 git commands to generate.