]> Joshua Wise's Git repositories - netwatch.git/blame - grubload/realmode.asm
Be more quiet about this whole transmit and receive business. This time, we actually...
[netwatch.git] / grubload / realmode.asm
CommitLineData
042eafc7
JW
1 [bits 32] ; Starts in 32 bit mode, then will drop back later.
2 org 0x4000
3entry:
4 cli
5 ; clean up 32 bit regs
6 mov eax, 0x0
7 mov ebx, 0x0
8 mov ecx, 0x0
9 mov edx, 0x0
10 mov esi, 0x0
11 mov edi, 0x0
12 mov ebp, 0x0
13 mov esp, 0x0
14
15 lgdt [gdtp]
16
17 mov ax, 0x10
18 mov ds, ax
19 mov es, ax
20 mov fs, ax
21 mov gs, ax
22 mov ss, ax
23
24 jmp 0x8:nextp ; Clear CS bits now too
25
26nextp:
27
28 mov eax, cr0
29 xor eax, 0x1 ; Clear PE
30 mov cr0, eax
31
32 jmp 0x0:nowreal ; and jmp away
33
34
35 [bits 16]
36nowreal:
37 mov long eax, 0x0000
38 mov ds, ax
39 mov es, ax
40 mov fs, ax
41 mov gs, ax
42 mov ss, ax
43
44 mov sp, 0xFFFF ; set up the stack
45
46 mov al, 0xAB
47 out 0x80, al
48
49 cli
50 lidt [idtp]
51
52 mov si, RETMSG
53 call disp
54
55 int 0x19 ; warm boot without clearing RAM.
56 call handload_drive ; hopefully shouldn't happen
57 ; ok, we give up
58 cli
59halt: hlt
60 jmp halt
61
62disp:
63 lodsb
64 or al, al
65 jz .done
66 mov ah, 0x0E
67 mov bx, 0x0007
68 int 0x10
69 jmp disp
70.done:
71 ret
72
73; handload_drive should be unnecessary; int 19 should take care of it for
74; us...
75handload_drive:
76 mov ax, 0x07C0
77 mov es, ax
78 mov ax, 0x0201 ; read one sector
79 mov bx, 0x0000 ; to the normal location
80 mov cx, 0x0001 ; disk sector 1
81 mov dx, 0x0080 ; drive 0
82 int 0x13
83 jc readerr
84
85 mov si, READSUCC
86 call disp
87
88 jmp 0x7C0:0x0 ; and return control to grub!
89readerr:
90 mov si, READFAIL
91 call disp
92 ret
93
94RETMSG db "SMM installer finished, booting your system of choice.",10,13,0
95READSUCC db "Read successful; rebooting into boot sector.",10,13,0
96READFAIL db "Boot disk read failure; system halted.",10,13,0
97
98
99idtp db 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00
100
101gdtp dw 0x1F
102 dd gdt
103
104gdt dd 0, 0
105 dd 0x0000FFFF, 0x00009e00 ; CS
106 dd 0x0000FFFF, 0x00009300 ; DS
This page took 0.026959 seconds and 4 git commands to generate.