-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgrub-0.97-gate-a20.patch
135 lines (121 loc) · 2.04 KB
/
grub-0.97-gate-a20.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
diff -ur grub-0.97.orig/stage2/asm.S grub-0.97/stage2/asm.S
--- grub-0.97.orig/stage2/asm.S 2009-11-12 16:35:33.000000000 -0500
+++ grub-0.97/stage2/asm.S 2009-11-12 17:39:23.000000000 -0500
@@ -1622,36 +1622,57 @@
*/
ENTRY(gateA20)
+ pushl %ebx
+ pushl %edx
+ call testA20
+ jnz 1f
+ call A20_BIOS
+ call testA20
+ jnz 1f
+ call A20_PORT92
+ call testA20
+ jnz 1f
+ call A20_KBDCTL
+ call testA20
+ jnz 1f
+ movl $0,%eax
+ jmp 2f
+1:
+ movl $-1,%eax
+2:
+ popl %edx
+ popl %ebx
+ ret
+
+testA20:
+ movl 0x500,%eax
+ movl 0x100500,%ebx
+ notl %eax
+ movl %eax,0x100500
+ cmpl %eax,0x500
+ pushfl
+ movl %ebx,0x100500
+ notl %eax
+ movl %eax,0x500
+ popfl
+ ret
+
+A20_BIOS:
/* first, try a BIOS call */
- pushl %ebp
- movl 8(%esp), %edx
call EXT_C(prot_to_real)
.code16
- movw $0x2400, %ax
- testw %dx, %dx
- jz 1f
- incw %ax
+ movw $0x2401, %ax
1: stc
int $0x15
- jnc 2f
-
- /* set non-zero if failed */
- movb $1, %ah
-
- /* save the status */
-2: movb %ah, %dl
DATA32 call EXT_C(real_to_prot)
.code32
-
- popl %ebp
- testb %dl, %dl
- jnz 3f
ret
-3: /*
+A20_PORT92:
+ /*
* try to switch gateA20 using PORT92, the "Fast A20 and Init"
* register
*/
@@ -1661,20 +1682,18 @@
cmpb $0xff, %al
jz 6f
- /* set or clear bit1, the ALT_A20_GATE bit */
- movb 4(%esp), %ah
- testb %ah, %ah
- jz 4f
+ /* set bit1, the ALT_A20_GATE bit */
orb $2, %al
- jmp 5f
-4: and $0xfd, %al
+ /* and $0xfd, %al */
/* clear the INIT_NOW bit; don't accidently reset the machine */
-5: and $0xfe, %al
+ and $0xfe, %al
outb %al, %dx
+6:
+ ret
-
-6: /* use keyboard controller */
+A20_KBDCTL:
+ /* use keyboard controller */
pushl %eax
call gloop1
@@ -1684,18 +1703,11 @@
gloopint1:
inb $K_STATUS
- cmpb $0xff, %al
- jz gloopint1_done
andb $K_IBUF_FUL, %al
jnz gloopint1
-gloopint1_done:
movb $KB_OUTPUT_MASK, %al
- cmpb $0, 0x8(%esp)
- jz gdoit
-
orb $KB_A20_ENABLE, %al
-gdoit:
outb $K_RDWR
call gloop1
@@ -1710,8 +1722,6 @@
gloop1:
inb $K_STATUS
- cmpb $0xff, %al
- jz gloop2ret
andb $K_IBUF_FUL, %al
jnz gloop1