|
@@ -21,124 +21,6 @@ FILE_LICENCE ( GPL2_OR_LATER )
|
21
|
21
|
|
22
|
22
|
.arch i386
|
23
|
23
|
|
24
|
|
-#define CR0_PE 1
|
25
|
|
-
|
26
|
|
-/****************************************************************************
|
27
|
|
- * flatten_real_mode
|
28
|
|
- *
|
29
|
|
- * Set up 4GB segment limits
|
30
|
|
- *
|
31
|
|
- * Parameters:
|
32
|
|
- * none
|
33
|
|
- * Returns:
|
34
|
|
- * none
|
35
|
|
- * Corrupts:
|
36
|
|
- * none
|
37
|
|
- ****************************************************************************
|
38
|
|
- */
|
39
|
|
- /* GDT for protected-mode calls */
|
40
|
|
- .section ".text16.early.data", "aw", @progbits
|
41
|
|
- .align 16
|
42
|
|
-flatten_gdt:
|
43
|
|
-flatten_gdt_limit: .word flatten_gdt_length - 1
|
44
|
|
-flatten_gdt_base: .long 0
|
45
|
|
- .word 0 /* padding */
|
46
|
|
-flatten_cs: /* 16-bit protected-mode flat code segment */
|
47
|
|
- .equ FLAT_CS, flatten_cs - flatten_gdt
|
48
|
|
- .word 0xffff, 0
|
49
|
|
- .byte 0, 0x9b, 0x8f, 0
|
50
|
|
-flatten_ss: /* 16-bit protected-mode flat stack segment */
|
51
|
|
- .equ FLAT_SS, flatten_ss - flatten_gdt
|
52
|
|
- .word 0xffff, 0
|
53
|
|
- .byte 0, 0x93, 0x8f, 0
|
54
|
|
-flatten_gdt_end:
|
55
|
|
- .equ flatten_gdt_length, . - flatten_gdt
|
56
|
|
- .size flatten_gdt, . - flatten_gdt
|
57
|
|
-
|
58
|
|
- .section ".text16.early.data", "aw", @progbits
|
59
|
|
- .align 16
|
60
|
|
-flatten_saved_gdt:
|
61
|
|
- .long 0, 0
|
62
|
|
- .size flatten_saved_gdt, . - flatten_saved_gdt
|
63
|
|
-
|
64
|
|
- .section ".text16.early", "awx", @progbits
|
65
|
|
- .code16
|
66
|
|
-flatten_real_mode:
|
67
|
|
- /* Preserve registers and flags */
|
68
|
|
- pushfl
|
69
|
|
- pushl %eax
|
70
|
|
- pushw %si
|
71
|
|
- pushw %gs
|
72
|
|
- pushw %fs
|
73
|
|
- pushw %es
|
74
|
|
- pushw %ds
|
75
|
|
- pushw %ss
|
76
|
|
-
|
77
|
|
- /* Set %ds for access to .text16.early.data variables */
|
78
|
|
- pushw %cs
|
79
|
|
- popw %ds
|
80
|
|
-
|
81
|
|
- /* Preserve original GDT */
|
82
|
|
- sgdt flatten_saved_gdt
|
83
|
|
-
|
84
|
|
- /* Set up GDT bases */
|
85
|
|
- xorl %eax, %eax
|
86
|
|
- movw %cs, %ax
|
87
|
|
- shll $4, %eax
|
88
|
|
- addl $flatten_gdt, %eax
|
89
|
|
- movl %eax, flatten_gdt_base
|
90
|
|
- movw %cs, %ax
|
91
|
|
- movw $flatten_cs, %si
|
92
|
|
- call set_seg_base
|
93
|
|
- movw %ss, %ax
|
94
|
|
- movw $flatten_ss, %si
|
95
|
|
- call set_seg_base
|
96
|
|
-
|
97
|
|
- /* Switch temporarily to protected mode and set segment registers */
|
98
|
|
- pushw %cs
|
99
|
|
- pushw $2f
|
100
|
|
- cli
|
101
|
|
- data32 lgdt flatten_gdt
|
102
|
|
- movl %cr0, %eax
|
103
|
|
- orb $CR0_PE, %al
|
104
|
|
- movl %eax, %cr0
|
105
|
|
- ljmp $FLAT_CS, $1f
|
106
|
|
-1: movw $FLAT_SS, %ax
|
107
|
|
- movw %ax, %ss
|
108
|
|
- movw %ax, %ds
|
109
|
|
- movw %ax, %es
|
110
|
|
- movw %ax, %fs
|
111
|
|
- movw %ax, %gs
|
112
|
|
- movl %cr0, %eax
|
113
|
|
- andb $0!CR0_PE, %al
|
114
|
|
- movl %eax, %cr0
|
115
|
|
- lret
|
116
|
|
-2: /* lret will ljmp to here */
|
117
|
|
-
|
118
|
|
- /* Restore GDT, registers and flags */
|
119
|
|
- data32 lgdt flatten_saved_gdt
|
120
|
|
- popw %ss
|
121
|
|
- popw %ds
|
122
|
|
- popw %es
|
123
|
|
- popw %fs
|
124
|
|
- popw %gs
|
125
|
|
- popw %si
|
126
|
|
- popl %eax
|
127
|
|
- popfl
|
128
|
|
- ret
|
129
|
|
- .size flatten_real_mode, . - flatten_real_mode
|
130
|
|
-
|
131
|
|
- .section ".text16.early", "awx", @progbits
|
132
|
|
- .code16
|
133
|
|
-set_seg_base:
|
134
|
|
- rolw $4, %ax
|
135
|
|
- movw %ax, 2(%si)
|
136
|
|
- andw $0xfff0, 2(%si)
|
137
|
|
- movb %al, 4(%si)
|
138
|
|
- andb $0x0f, 4(%si)
|
139
|
|
- ret
|
140
|
|
- .size set_seg_base, . - set_seg_base
|
141
|
|
-
|
142
|
24
|
/****************************************************************************
|
143
|
25
|
* test_a20_short, test_a20_long
|
144
|
26
|
*
|
|
@@ -403,7 +285,7 @@ enable_a20_method:
|
403
|
285
|
/****************************************************************************
|
404
|
286
|
* access_highmem (real mode far call)
|
405
|
287
|
*
|
406
|
|
- * Open up access to high memory in flat real mode with A20 enabled
|
|
288
|
+ * Open up access to high memory with A20 enabled
|
407
|
289
|
*
|
408
|
290
|
* Parameters:
|
409
|
291
|
* none
|
|
@@ -419,7 +301,5 @@ enable_a20_method:
|
419
|
301
|
access_highmem:
|
420
|
302
|
/* Enable A20 line */
|
421
|
303
|
call enable_a20
|
422
|
|
- /* Set up 4GB limits */
|
423
|
|
- call flatten_real_mode
|
424
|
304
|
lret
|
425
|
305
|
.size access_highmem, . - access_highmem
|