]> Joshua Wise's Git repositories - netwatch.git/blob - aseg/aseg.asm
Move more functionality out to C
[netwatch.git] / aseg / aseg.asm
1         org 0xA8000
2 [bits 16]
3 entry:
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
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]
25
26         mov al, [needclear]
27         cmp al, 0
28         jz noclear
29         mov al, 0                       ; clear BSS
30         mov edi, [dataptr+4]
31         mov ecx, [dataptr+8]
32         rep stosb
33         mov [needclear], al
34         
35 noclear:
36         mov eax, [dataptr+12]           ; jump into C
37         call eax
38
39         mov al, 0x40                    ; ack the periodic IRQ
40         mov dx, 0x834
41         out dx, al
42         
43         mov dx, 0x830                   ; now ack the SMI itself
44         in al, dx
45         or al, 0x02
46         and al, 0xBF
47         out dx, al
48         or al, 0x40
49         out dx, al
50
51         rsm                             ; and leave SMM
52
53         align 0x4
54 gdtr:
55         db 0x27, 0x00
56         dd gdt
57         align 0x4
58 gdt:
59         db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
60         db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x93, 0xCF, 0x00       ; data segment
61         db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9B, 0xCF, 0x00       ; code segment
62         db 0xFF, 0xFF, 0x00, 0x80, 0x0A, 0x9B, 0xCF, 0x00       ; code segment for trampoline
63
64 needclear:
65         db 0x01
66
67 dataptr:
68         ; 4 bytes of stack top
69         ; 4 bytes of BSS start
70         ; 4 bytes of BSS length
71         ; 4 bytes of C entry point
72         ; These show up 
This page took 0.026163 seconds and 4 git commands to generate.