|
@@ -17,6 +17,10 @@
|
17
|
17
|
*
|
18
|
18
|
*/
|
19
|
19
|
|
|
20
|
+ .arch i386
|
|
21
|
+ .section ".prefix.lib", "awx", @progbits
|
|
22
|
+ .section ".data16", "aw", @progbits
|
|
23
|
+
|
20
|
24
|
/**
|
21
|
25
|
* High memory temporary load address
|
22
|
26
|
*
|
|
@@ -27,24 +31,125 @@
|
27
|
31
|
* We use the start of an even megabyte so that we don't have to worry
|
28
|
32
|
* about the current state of the A20 line.
|
29
|
33
|
*
|
30
|
|
- * We use 4MB rather than 2MB because there is at least one commercial
|
31
|
|
- * PXE ROM ("Broadcom UNDI, PXE-2.1 (build 082) v2.0.4") which stores
|
32
|
|
- * data required by the UNDI ROM loader (yes, the ROM loader; that's
|
33
|
|
- * the component which should be impossible to damage short of
|
34
|
|
- * screwing with the MMU) around the 2MB mark. Sadly, this is not a
|
35
|
|
- * joke.
|
36
|
|
- *
|
|
34
|
+ * We use 4MB rather than 2MB because some PXE stack / PMM BIOS
|
|
35
|
+ * combinations are known to place data required by other UNDI ROMs
|
|
36
|
+ * loader around the 2MB mark.
|
37
|
37
|
*/
|
38
|
|
-#define HIGHMEM_LOADPOINT ( 4 << 20 )
|
|
38
|
+ .globl HIGHMEM_LOADPOINT
|
|
39
|
+ .equ HIGHMEM_LOADPOINT, ( 4 << 20 )
|
39
|
40
|
|
40
|
41
|
/* Image compression enabled */
|
41
|
42
|
#define COMPRESS 1
|
42
|
43
|
|
43
|
44
|
#define CR0_PE 1
|
44
|
45
|
|
45
|
|
- .arch i386
|
46
|
|
- .section ".prefix.lib", "awx", @progbits
|
47
|
|
- .section ".data16", "aw", @progbits
|
|
46
|
+/*****************************************************************************
|
|
47
|
+ * Utility function: print character (with LF -> LF,CR translation)
|
|
48
|
+ *
|
|
49
|
+ * Parameters:
|
|
50
|
+ * %al : character to print
|
|
51
|
+ * Returns:
|
|
52
|
+ * Nothing
|
|
53
|
+ * Corrupts:
|
|
54
|
+ * %ax
|
|
55
|
+ *****************************************************************************
|
|
56
|
+ */
|
|
57
|
+ .section ".prefix.lib"
|
|
58
|
+ .code16
|
|
59
|
+ .globl print_character
|
|
60
|
+print_character:
|
|
61
|
+ /* Preserve registers */
|
|
62
|
+ pushw %bx
|
|
63
|
+ pushw %bp
|
|
64
|
+ /* Print character */
|
|
65
|
+ movw $0x0007, %bx /* page 0, attribute 7 (normal) */
|
|
66
|
+ movb $0x0e, %ah /* write char, tty mode */
|
|
67
|
+ cmpb $0x0a, %al /* '\n'? */
|
|
68
|
+ jne 1f
|
|
69
|
+ int $0x10
|
|
70
|
+ movb $0x0d, %al
|
|
71
|
+1: int $0x10
|
|
72
|
+ /* Restore registers and return */
|
|
73
|
+ popw %bp
|
|
74
|
+ popw %bx
|
|
75
|
+ ret
|
|
76
|
+ .size print_character, . - print_character
|
|
77
|
+
|
|
78
|
+/*****************************************************************************
|
|
79
|
+ * Utility function: print a NUL-terminated string
|
|
80
|
+ *
|
|
81
|
+ * Parameters:
|
|
82
|
+ * %ds:si : string to print
|
|
83
|
+ * Returns:
|
|
84
|
+ * %ds:si : character after terminating NUL
|
|
85
|
+ *****************************************************************************
|
|
86
|
+ */
|
|
87
|
+ .section ".prefix.lib"
|
|
88
|
+ .code16
|
|
89
|
+ .globl print_message
|
|
90
|
+print_message:
|
|
91
|
+ /* Preserve registers */
|
|
92
|
+ pushw %ax
|
|
93
|
+ /* Print string */
|
|
94
|
+1: lodsb
|
|
95
|
+ testb %al, %al
|
|
96
|
+ je 2f
|
|
97
|
+ call print_character
|
|
98
|
+ jmp 1b
|
|
99
|
+2: /* Restore registers and return */
|
|
100
|
+ popw %ax
|
|
101
|
+ ret
|
|
102
|
+ .size print_message, . - print_message
|
|
103
|
+
|
|
104
|
+/*****************************************************************************
|
|
105
|
+ * Utility functions: print hex digit/byte/word/dword
|
|
106
|
+ *
|
|
107
|
+ * Parameters:
|
|
108
|
+ * %al (low nibble) : digit to print
|
|
109
|
+ * %al : byte to print
|
|
110
|
+ * %ax : word to print
|
|
111
|
+ * %eax : dword to print
|
|
112
|
+ * Returns:
|
|
113
|
+ * Nothing
|
|
114
|
+ *****************************************************************************
|
|
115
|
+ */
|
|
116
|
+ .section ".prefix.lib"
|
|
117
|
+ .code16
|
|
118
|
+ .globl print_hex_dword
|
|
119
|
+print_hex_dword:
|
|
120
|
+ rorl $16, %eax
|
|
121
|
+ call print_hex_word
|
|
122
|
+ rorl $16, %eax
|
|
123
|
+ /* Fall through */
|
|
124
|
+ .size print_hex_dword, . - print_hex_dword
|
|
125
|
+ .globl print_hex_word
|
|
126
|
+print_hex_word:
|
|
127
|
+ xchgb %al, %ah
|
|
128
|
+ call print_hex_byte
|
|
129
|
+ xchgb %al, %ah
|
|
130
|
+ /* Fall through */
|
|
131
|
+ .size print_hex_word, . - print_hex_word
|
|
132
|
+ .globl print_hex_byte
|
|
133
|
+print_hex_byte:
|
|
134
|
+ rorb $4, %al
|
|
135
|
+ call print_hex_nibble
|
|
136
|
+ rorb $4, %al
|
|
137
|
+ /* Fall through */
|
|
138
|
+ .size print_hex_byte, . - print_hex_byte
|
|
139
|
+ .globl print_hex_nibble
|
|
140
|
+print_hex_nibble:
|
|
141
|
+ /* Preserve registers */
|
|
142
|
+ pushw %ax
|
|
143
|
+ /* Print digit (technique by Norbert Juffa <norbert.juffa@amd.com> */
|
|
144
|
+ andb $0x0f, %al
|
|
145
|
+ cmpb $10, %al
|
|
146
|
+ sbbb $0x69, %al
|
|
147
|
+ das
|
|
148
|
+ call print_character
|
|
149
|
+ /* Restore registers and return */
|
|
150
|
+ popw %ax
|
|
151
|
+ ret
|
|
152
|
+ .size print_hex_nibble, . - print_hex_nibble
|
48
|
153
|
|
49
|
154
|
/****************************************************************************
|
50
|
155
|
* pm_call (real-mode near call)
|
|
@@ -70,13 +175,14 @@
|
70
|
175
|
#ifndef KEEP_IT_REAL
|
71
|
176
|
|
72
|
177
|
/* GDT for protected-mode calls */
|
73
|
|
- .section ".data16"
|
|
178
|
+ .section ".prefix.lib"
|
74
|
179
|
.align 16
|
|
180
|
+pm_call_vars:
|
75
|
181
|
gdt:
|
76
|
182
|
gdt_limit: .word gdt_length - 1
|
77
|
183
|
gdt_base: .long 0
|
78
|
184
|
.word 0 /* padding */
|
79
|
|
-pm_cs: /* 16-bit protected-mode code segment */
|
|
185
|
+pm_cs: /* 16-bit protected-mode code segment */
|
80
|
186
|
.equ PM_CS, pm_cs - gdt
|
81
|
187
|
.word 0xffff, 0
|
82
|
188
|
.byte 0, 0x9b, 0x00, 0
|
|
@@ -92,18 +198,24 @@ gdt_end:
|
92
|
198
|
.equ gdt_length, . - gdt
|
93
|
199
|
.size gdt, . - gdt
|
94
|
200
|
|
95
|
|
- .section ".data16"
|
|
201
|
+ .section ".prefix.lib"
|
96
|
202
|
.align 16
|
97
|
203
|
pm_saved_gdt:
|
98
|
204
|
.long 0, 0
|
99
|
205
|
.size pm_saved_gdt, . - pm_saved_gdt
|
100
|
206
|
|
|
207
|
+ .equ pm_call_vars_size, . - pm_call_vars
|
|
208
|
+#define PM_CALL_VAR(x) ( -pm_call_vars_size + ( (x) - pm_call_vars ) )
|
|
209
|
+
|
101
|
210
|
.section ".prefix.lib"
|
102
|
211
|
.code16
|
103
|
212
|
pm_call:
|
104
|
|
- /* Preserve registers, flags, GDT, and RM return point */
|
|
213
|
+ /* Preserve registers, flags, and RM return point */
|
|
214
|
+ pushw %bp
|
|
215
|
+ movw %sp, %bp
|
|
216
|
+ subw $pm_call_vars_size, %sp
|
|
217
|
+ andw $0xfff0, %sp
|
105
|
218
|
pushfl
|
106
|
|
- sgdt pm_saved_gdt
|
107
|
219
|
pushw %gs
|
108
|
220
|
pushw %fs
|
109
|
221
|
pushw %es
|
|
@@ -112,27 +224,43 @@ pm_call:
|
112
|
224
|
pushw %cs
|
113
|
225
|
pushw $99f
|
114
|
226
|
|
|
227
|
+ /* Set up local variable block, and preserve GDT */
|
|
228
|
+ pushw %cx
|
|
229
|
+ pushw %si
|
|
230
|
+ pushw %di
|
|
231
|
+ pushw %ss
|
|
232
|
+ popw %es
|
|
233
|
+ movw $pm_call_vars, %si
|
|
234
|
+ leaw PM_CALL_VAR(pm_call_vars)(%bp), %di
|
|
235
|
+ movw $pm_call_vars_size, %cx
|
|
236
|
+ cs rep movsb
|
|
237
|
+ popw %di
|
|
238
|
+ popw %si
|
|
239
|
+ popw %cx
|
|
240
|
+ sgdt PM_CALL_VAR(pm_saved_gdt)(%bp)
|
|
241
|
+
|
115
|
242
|
/* Set up GDT bases */
|
116
|
243
|
pushl %eax
|
117
|
|
- pushw %bx
|
|
244
|
+ pushl %edi
|
118
|
245
|
xorl %eax, %eax
|
119
|
|
- movw %ds, %ax
|
|
246
|
+ movw %ss, %ax
|
120
|
247
|
shll $4, %eax
|
121
|
|
- addl $gdt, %eax
|
122
|
|
- movl %eax, gdt_base
|
|
248
|
+ movzwl %bp, %edi
|
|
249
|
+ leal PM_CALL_VAR(gdt)(%eax, %edi), %eax
|
|
250
|
+ movl %eax, PM_CALL_VAR(gdt_base)(%bp)
|
123
|
251
|
movw %cs, %ax
|
124
|
|
- movw $pm_cs, %bx
|
|
252
|
+ movw $PM_CALL_VAR(pm_cs), %di
|
125
|
253
|
call set_seg_base
|
126
|
254
|
movw %ss, %ax
|
127
|
|
- movw $pm_ss, %bx
|
|
255
|
+ movw $PM_CALL_VAR(pm_ss), %di
|
128
|
256
|
call set_seg_base
|
129
|
|
- popw %bx
|
|
257
|
+ popl %edi
|
130
|
258
|
popl %eax
|
131
|
259
|
|
132
|
260
|
/* Switch CPU to protected mode and load up segment registers */
|
133
|
261
|
pushl %eax
|
134
|
262
|
cli
|
135
|
|
- lgdt gdt
|
|
263
|
+ lgdt PM_CALL_VAR(gdt)(%bp)
|
136
|
264
|
movl %cr0, %eax
|
137
|
265
|
orb $CR0_PE, %al
|
138
|
266
|
movl %eax, %cr0
|
|
@@ -168,18 +296,19 @@ pm_call:
|
168
|
296
|
popw %es
|
169
|
297
|
popw %fs
|
170
|
298
|
popw %gs
|
171
|
|
- lgdt pm_saved_gdt
|
|
299
|
+ lgdt PM_CALL_VAR(pm_saved_gdt)(%bp)
|
172
|
300
|
popfl
|
173
|
|
-
|
|
301
|
+ movw %bp, %sp
|
|
302
|
+ popw %bp
|
174
|
303
|
ret
|
175
|
304
|
.size pm_call, . - pm_call
|
176
|
305
|
|
177
|
306
|
set_seg_base:
|
178
|
307
|
rolw $4, %ax
|
179
|
|
- movw %ax, 2(%bx)
|
180
|
|
- andw $0xfff0, 2(%bx)
|
181
|
|
- movb %al, 4(%bx)
|
182
|
|
- andb $0x0f, 4(%bx)
|
|
308
|
+ movw %ax, 2(%bp,%di)
|
|
309
|
+ andw $0xfff0, 2(%bp,%di)
|
|
310
|
+ movb %al, 4(%bp,%di)
|
|
311
|
+ andb $0x0f, 4(%bp,%di)
|
183
|
312
|
ret
|
184
|
313
|
.size set_seg_base, . - set_seg_base
|
185
|
314
|
|
|
@@ -196,7 +325,7 @@ set_seg_base:
|
196
|
325
|
* %ecx : length
|
197
|
326
|
* Returns:
|
198
|
327
|
* %ds:esi : next source address
|
199
|
|
- * %ds:esi : next destination address
|
|
328
|
+ * %es:edi : next destination address
|
200
|
329
|
* Corrupts:
|
201
|
330
|
* None
|
202
|
331
|
****************************************************************************
|
|
@@ -211,24 +340,57 @@ copy_bytes:
|
211
|
340
|
.size copy_bytes, . - copy_bytes
|
212
|
341
|
|
213
|
342
|
/****************************************************************************
|
214
|
|
- * install_block (real-mode or 16-bit protected-mode near call)
|
|
343
|
+ * install_block (real-mode near call)
|
215
|
344
|
*
|
216
|
345
|
* Install block to specified address
|
217
|
346
|
*
|
218
|
347
|
* Parameters:
|
219
|
|
- * %ds:esi : source address (must be a multiple of 16)
|
220
|
|
- * %es:edi : destination address
|
|
348
|
+ * %esi : source physical address (must be a multiple of 16)
|
|
349
|
+ * %edi : destination physical address (must be a multiple of 16)
|
221
|
350
|
* %ecx : length of (decompressed) data
|
222
|
351
|
* %edx : total length of block (including any uninitialised data portion)
|
223
|
352
|
* Returns:
|
224
|
|
- * %ds:esi : next source address (will be a multiple of 16)
|
|
353
|
+ * %esi : next source physical address (will be a multiple of 16)
|
225
|
354
|
* Corrupts:
|
226
|
|
- * %edi, %ecx, %edx
|
|
355
|
+ * none
|
227
|
356
|
****************************************************************************
|
228
|
357
|
*/
|
229
|
358
|
.section ".prefix.lib"
|
230
|
359
|
.code16
|
231
|
360
|
install_block:
|
|
361
|
+
|
|
362
|
+#ifdef KEEP_IT_REAL
|
|
363
|
+
|
|
364
|
+ /* Preserve registers */
|
|
365
|
+ pushw %ds
|
|
366
|
+ pushw %es
|
|
367
|
+ pushl %ecx
|
|
368
|
+ pushl %edi
|
|
369
|
+
|
|
370
|
+ /* Convert %esi and %edi to segment registers */
|
|
371
|
+ shrl $4, %esi
|
|
372
|
+ movw %si, %ds
|
|
373
|
+ xorw %si, %si
|
|
374
|
+ shrl $4, %edi
|
|
375
|
+ movw %di, %es
|
|
376
|
+ xorw %di, %di
|
|
377
|
+
|
|
378
|
+#else /* KEEP_IT_REAL */
|
|
379
|
+
|
|
380
|
+ /* Call self in protected mode */
|
|
381
|
+ pushw %ax
|
|
382
|
+ movw $1f, %ax
|
|
383
|
+ call pm_call
|
|
384
|
+ popw %ax
|
|
385
|
+ ret
|
|
386
|
+1:
|
|
387
|
+ /* Preserve registers */
|
|
388
|
+ pushl %ecx
|
|
389
|
+ pushl %edi
|
|
390
|
+
|
|
391
|
+#endif /* KEEP_IT_REAL */
|
|
392
|
+
|
|
393
|
+
|
232
|
394
|
#if COMPRESS
|
233
|
395
|
/* Decompress source to destination */
|
234
|
396
|
call decompress16
|
|
@@ -249,6 +411,28 @@ install_block:
|
249
|
411
|
addl $0xf, %esi
|
250
|
412
|
andl $~0xf, %esi
|
251
|
413
|
|
|
414
|
+
|
|
415
|
+#ifdef KEEP_IT_REAL
|
|
416
|
+
|
|
417
|
+ /* Convert %ds:esi back to a physical address */
|
|
418
|
+ movzwl %ds, %cx
|
|
419
|
+ shll $4, %ecx
|
|
420
|
+ addl %ecx, %esi
|
|
421
|
+
|
|
422
|
+ /* Restore registers */
|
|
423
|
+ popl %edi
|
|
424
|
+ popl %ecx
|
|
425
|
+ popw %es
|
|
426
|
+ popw %ds
|
|
427
|
+
|
|
428
|
+#else /* KEEP_IT_REAL */
|
|
429
|
+
|
|
430
|
+ /* Restore registers */
|
|
431
|
+ popl %edi
|
|
432
|
+ popl %ecx
|
|
433
|
+
|
|
434
|
+#endif
|
|
435
|
+
|
252
|
436
|
ret
|
253
|
437
|
.size install_block, . - install_block
|
254
|
438
|
|
|
@@ -270,6 +454,7 @@ install_block:
|
270
|
454
|
*/
|
271
|
455
|
.section ".prefix.lib"
|
272
|
456
|
.code16
|
|
457
|
+ .globl alloc_basemem
|
273
|
458
|
alloc_basemem:
|
274
|
459
|
/* FBMS => %ax as segment address */
|
275
|
460
|
movw $0x40, %ax
|
|
@@ -296,137 +481,86 @@ alloc_basemem:
|
296
|
481
|
.size alloc_basemem, . - alloc_basemem
|
297
|
482
|
|
298
|
483
|
/****************************************************************************
|
299
|
|
- * install_basemem (real-mode near call)
|
|
484
|
+ * install (real-mode near call)
|
300
|
485
|
*
|
301
|
|
- * Install source block into base memory
|
|
486
|
+ * Install all text and data segments.
|
302
|
487
|
*
|
303
|
488
|
* Parameters:
|
304
|
|
- * %esi : source physical address (must be a multiple of 16)
|
305
|
|
- * %es : destination segment address
|
306
|
|
- * %cx : length of (decompressed) data
|
307
|
|
- * %dx : total length of block (including any uninitialised data portion)
|
|
489
|
+ * none
|
308
|
490
|
* Returns:
|
309
|
|
- * %esi : next source physical address (will be a multiple of 16)
|
|
491
|
+ * %ax : .text16 segment address
|
|
492
|
+ * %bx : .data16 segment address
|
310
|
493
|
* Corrupts:
|
311
|
|
- * %edi, %ecx, %edx
|
|
494
|
+ * none
|
312
|
495
|
****************************************************************************
|
313
|
496
|
*/
|
314
|
497
|
.section ".prefix.lib"
|
315
|
498
|
.code16
|
316
|
|
-install_basemem:
|
|
499
|
+ .globl install
|
|
500
|
+install:
|
317
|
501
|
/* Preserve registers */
|
318
|
|
- pushw %ds
|
319
|
|
-
|
320
|
|
- /* Preserve original %esi */
|
321
|
502
|
pushl %esi
|
322
|
|
-
|
323
|
|
- /* Install to specified address */
|
324
|
|
- shrl $4, %esi
|
325
|
|
- movw %si, %ds
|
326
|
|
- xorw %si, %si
|
327
|
|
- xorl %edi, %edi
|
328
|
|
- movzwl %cx, %ecx
|
329
|
|
- movzwl %dx, %edx
|
330
|
|
- call install_block
|
331
|
|
-
|
332
|
|
- /* Fix up %esi for return */
|
333
|
|
- popl %ecx
|
334
|
|
- addl %ecx, %esi
|
335
|
|
-
|
336
|
|
- /* Restore registers */
|
337
|
|
- popw %ds
|
|
503
|
+ pushl %edi
|
|
504
|
+ /* Allocate space for .text16 and .data16 */
|
|
505
|
+ call alloc_basemem
|
|
506
|
+ /* Image source = %cs:0000 */
|
|
507
|
+ xorl %esi, %esi
|
|
508
|
+ /* Image destination = HIGHMEM_LOADPOINT */
|
|
509
|
+ movl $HIGHMEM_LOADPOINT, %edi
|
|
510
|
+ /* Install text and data segments */
|
|
511
|
+ call install_prealloc
|
|
512
|
+ /* Restore registers and return */
|
|
513
|
+ popl %edi
|
|
514
|
+ popl %esi
|
338
|
515
|
ret
|
339
|
|
- .size install_basemem, . - install_basemem
|
340
|
|
-
|
341
|
|
-/****************************************************************************
|
342
|
|
- * install_highmem (real-mode near call)
|
343
|
|
- *
|
344
|
|
- * Install source block into high memory
|
345
|
|
- *
|
346
|
|
- * Parameters:
|
347
|
|
- * %esi : source physical address (must be a multiple of 16)
|
348
|
|
- * %edi : destination physical address
|
349
|
|
- * %ecx : length of (decompressed) data
|
350
|
|
- * %edx : total length of block (including any uninitialised data portion)
|
351
|
|
- * Returns:
|
352
|
|
- * %esi : next source physical address (will be a multiple of 16)
|
353
|
|
- * Corrupts:
|
354
|
|
- * %edi, %ecx, %edx
|
355
|
|
- ****************************************************************************
|
356
|
|
- */
|
357
|
|
-
|
358
|
|
-#ifndef KEEP_IT_REAL
|
359
|
|
-
|
360
|
|
- .section ".prefix.lib"
|
361
|
|
- .code16
|
362
|
|
-install_highmem:
|
363
|
|
- /* Preserve registers */
|
364
|
|
- pushw %ax
|
365
|
|
-
|
366
|
|
- /* Install to specified address */
|
367
|
|
- movw $install_block, %ax
|
368
|
|
- call pm_call
|
|
516
|
+ .size install, . - install
|
369
|
517
|
|
370
|
|
- /* Restore registers */
|
371
|
|
- popw %ax
|
372
|
|
- ret
|
373
|
|
- .size install_highmem, . - install_highmem
|
374
|
|
-
|
375
|
|
-#endif /* KEEP_IT_REAL */
|
376
|
|
-
|
377
|
518
|
/****************************************************************************
|
378
|
|
- * install (real-mode near call)
|
379
|
519
|
* install_prealloc (real-mode near call)
|
380
|
520
|
*
|
381
|
521
|
* Install all text and data segments.
|
382
|
522
|
*
|
383
|
523
|
* Parameters:
|
384
|
|
- * %ax : .text16 segment address (install_prealloc only)
|
385
|
|
- * %bx : .data16 segment address (install_prealloc only)
|
386
|
|
- * Returns:
|
387
|
|
- * %ax : .text16 segment address
|
388
|
|
- * %bx : .data16 segment address
|
389
|
|
- * %edi : .text physical address (if applicable)
|
|
524
|
+ * %ax : .text16 segment address
|
|
525
|
+ * %bx : .data16 segment address
|
|
526
|
+ * %esi : Image source physical address (or zero for %cs:0000)
|
|
527
|
+ * %edi : Decompression temporary area physical address
|
390
|
528
|
* Corrupts:
|
391
|
529
|
* none
|
392
|
530
|
****************************************************************************
|
393
|
531
|
*/
|
394
|
532
|
.section ".prefix.lib"
|
395
|
533
|
.code16
|
396
|
|
- .globl install
|
397
|
|
-install:
|
398
|
|
- /* Allocate space for .text16 and .data16 */
|
399
|
|
- call alloc_basemem
|
400
|
|
- .size install, . - install
|
401
|
534
|
.globl install_prealloc
|
402
|
535
|
install_prealloc:
|
403
|
536
|
/* Save registers */
|
|
537
|
+ pushal
|
404
|
538
|
pushw %ds
|
405
|
539
|
pushw %es
|
406
|
|
- pushl %esi
|
407
|
|
- pushl %ecx
|
408
|
|
- pushl %edx
|
409
|
540
|
|
410
|
541
|
/* Sanity: clear the direction flag asap */
|
411
|
542
|
cld
|
412
|
543
|
|
413
|
544
|
/* Calculate physical address of payload (i.e. first source) */
|
414
|
|
- xorl %esi, %esi
|
|
545
|
+ testl %esi, %esi
|
|
546
|
+ jnz 1f
|
415
|
547
|
movw %cs, %si
|
416
|
548
|
shll $4, %esi
|
417
|
|
- addl $_payload_offset, %esi
|
418
|
|
-
|
419
|
|
- /* Install .text16 */
|
420
|
|
- movw %ax, %es
|
421
|
|
- movw $_text16_size, %cx
|
422
|
|
- movw %cx, %dx
|
423
|
|
- call install_basemem
|
|
549
|
+1: addl $_payload_offset, %esi
|
424
|
550
|
|
425
|
|
- /* Install .data16 */
|
426
|
|
- movw %bx, %es
|
427
|
|
- movw $_data16_progbits_size, %cx
|
428
|
|
- movw $_data16_size, %dx
|
429
|
|
- call install_basemem
|
|
551
|
+ /* Install .text16 and .data16 */
|
|
552
|
+ pushl %edi
|
|
553
|
+ movzwl %ax, %edi
|
|
554
|
+ shll $4, %edi
|
|
555
|
+ movl $_text16_size, %ecx
|
|
556
|
+ movl %ecx, %edx
|
|
557
|
+ call install_block /* .text16 */
|
|
558
|
+ movzwl %bx, %edi
|
|
559
|
+ shll $4, %edi
|
|
560
|
+ movl $_data16_progbits_size, %ecx
|
|
561
|
+ movl $_data16_size, %edx
|
|
562
|
+ call install_block /* .data16 */
|
|
563
|
+ popl %edi
|
430
|
564
|
|
431
|
565
|
/* Set up %ds for access to .data16 */
|
432
|
566
|
movw %bx, %ds
|
|
@@ -440,12 +574,9 @@ install_prealloc:
|
440
|
574
|
* prior to reading the E820 memory map and relocating
|
441
|
575
|
* properly.
|
442
|
576
|
*/
|
443
|
|
- movl $HIGHMEM_LOADPOINT, %edi
|
444
|
577
|
movl $_textdata_progbits_size, %ecx
|
445
|
578
|
movl $_textdata_size, %edx
|
446
|
|
- pushl %edi
|
447
|
|
- call install_highmem
|
448
|
|
- popl %edi
|
|
579
|
+ call install_block
|
449
|
580
|
|
450
|
581
|
/* Initialise librm at current location */
|
451
|
582
|
movw %ax, (init_librm_vector+2)
|
|
@@ -473,11 +604,9 @@ install_prealloc:
|
473
|
604
|
|
474
|
605
|
#endif
|
475
|
606
|
/* Restore registers */
|
476
|
|
- popl %edx
|
477
|
|
- popl %ecx
|
478
|
|
- popl %esi
|
479
|
607
|
popw %es
|
480
|
608
|
popw %ds
|
|
609
|
+ popal
|
481
|
610
|
ret
|
482
|
611
|
.size install_prealloc, . - install_prealloc
|
483
|
612
|
|