]> Joshua Wise's Git repositories - netwatch.git/blame_incremental - netwatch/entry.asm
Fix smm_type detection to actually detect, and add a state_num_regs routine.
[netwatch.git] / netwatch / entry.asm
... / ...
CommitLineData
1; entry.asm
2; SMI entry point
3; NetWatch system management mode administration console
4;
5; Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved.
6; This program is free software; you can redistribute and/or modify it under
7; the terms found in the file LICENSE in the root of this source tree.
8
9 org 0xA8000
10[bits 16]
11entry:
12 mov ax, 0xA800 ; Take us out of flat unreal mode,
13 mov ds, ax ; and put us in true real mode.
14 mov es, ax
15 mov fs, ax
16 mov gs, ax
17 mov ss, ax
18 jmp 0xA800:(entry2-0xA8000) ; Long jump to a correct cs.
19entry2:
20 lgdt [(gdtr-0xA8000)] ; Set up a new GDT.
21 mov eax, 0x1
22 mov cr0, eax ; ... and enter pmode!
23 jmp long 0x10:continue ; Now longjmp into the new code.
24[bits 32]
25continue:
26 mov ax, 0x08 ; Set up segment selectors.
27 mov ds, ax
28 mov es, ax
29 mov fs, ax
30 mov gs, ax
31 mov ss, ax
32 mov esp, [dataptr] ; Load stack pointer.
33
34 ; Before we do anything, turn off alignment checking.
35 pushf
36 pop eax
37 and eax, ~(1 << 18)
38 push eax
39 popf
40
41 mov eax, [dataptr+4] ; Load target jump address
42 call eax ; then jump into C.
43
44 rsm ; and leave SMM
45
46 align 0x4
47gdtr:
48 db 0x17, 0x00
49 dd gdt
50 align 0x4
51gdt:
52 db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; initial null entry
53 db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x93, 0xCF, 0x00 ; data segment
54 db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9B, 0xCF, 0x00 ; code segment
55
56
57dataptr:
58 ; 4 bytes of stack top
59 ; 4 bytes of C entry point
60 ; These show up
This page took 0.024791 seconds and 4 git commands to generate.