Преглед изворни кода

Use a single _payload_offset linker-defined variable to locate the

start of the non-prefix blocks in the loaded image, and rely on the
image ordering.  This should make introducing compression much easier.
tags/v0.9.3
Michael Brown пре 17 година
родитељ
комит
ab859a5355
2 измењених фајлова са 23 додато и 16 уклоњено
  1. 21
    16
      src/arch/i386/prefix/libprefix.S
  2. 2
    0
      src/arch/i386/scripts/i386.lds

+ 21
- 16
src/arch/i386/prefix/libprefix.S Прегледај датотеку

@@ -49,14 +49,14 @@
49 49
  * Install block to specified address
50 50
  *
51 51
  * Parameters:
52
- *   %esi : byte offset within loaded image (must be a multiple of 16)
52
+ *   %esi : start offset within loaded image (must be a multiple of 16)
53 53
  *   %es:edi : destination address
54 54
  *   %ecx : length of (decompressed) data
55 55
  *   %edx : total length of block (including any uninitialised data portion)
56 56
  * Returns:
57
- *   none
57
+ *   %esi : end offset within image (rounded up to next multiple of 16)
58 58
  * Corrupts:
59
- *   %esi, %edi, %ecx, %edx
59
+ *   %edi, %ecx, %edx
60 60
  ****************************************************************************
61 61
  */
62 62
 	.section ".prefix.lib"
@@ -65,6 +65,8 @@ install_block:
65 65
 	/* Preserve registers */
66 66
 	pushw	%ds
67 67
 	pushl	%eax
68
+	pushl	%ebx
69
+	movl	%esi, %ebx
68 70
 	
69 71
 	/* Starting segment => %ds */
70 72
 	movw	%cs, %ax
@@ -87,7 +89,13 @@ install_block:
87 89
 	xorb	%al, %al
88 90
 	rep addr32 stosb
89 91
 
92
+	/* Adjust %esi */
93
+	addl	%ebx, %esi
94
+	addl	$0xf, %esi
95
+	andl	$~0xf, %esi
96
+
90 97
 	/* Restore registers */
98
+	popl	%ebx
91 99
 	popl	%eax
92 100
 	popw	%ds
93 101
 	ret
@@ -144,8 +152,9 @@ alloc_basemem:
144 152
  * Parameters: 
145 153
  *   %ax : .text16 segment address
146 154
  *   %bx : .data16 segment address
155
+ *   %esi : start offset within loaded image (must be a multiple of 16)
147 156
  * Returns:
148
- *   none
157
+ *   %esi : end offset within image (rounded up to next multiple of 16)
149 158
  * Corrupts:
150 159
  *   none
151 160
  ****************************************************************************
@@ -155,7 +164,6 @@ alloc_basemem:
155 164
 install_basemem:
156 165
 	/* Preserve registers */
157 166
 	pushw	%es
158
-	pushl	%esi
159 167
 	pushl	%edi
160 168
 	pushl	%ecx
161 169
 	pushl	%edx
@@ -163,7 +171,6 @@ install_basemem:
163 171
 	/* Install .text16 */
164 172
 	movw	%ax, %es
165 173
 	xorl	%edi, %edi
166
-	movl	$_text16_load_offset, %esi
167 174
 	movl	$_text16_size, %ecx
168 175
 	movl	%ecx, %edx
169 176
 	call	install_block
@@ -171,7 +178,6 @@ install_basemem:
171 178
 	/* Install .data16 */
172 179
 	movw	%bx, %es
173 180
 	xorl	%edi, %edi	
174
-	movl	$_data16_load_offset, %esi
175 181
 	movl	$_data16_progbits_size, %ecx
176 182
 	movl	$_data16_size, %edx
177 183
 	call	install_block
@@ -180,7 +186,6 @@ install_basemem:
180 186
 	popl	%edx
181 187
 	popl	%ecx
182 188
 	popl	%edi
183
-	popl	%esi
184 189
 	popw	%es
185 190
 	ret
186 191
 	.size install_basemem, . - install_basemem
@@ -191,9 +196,10 @@ install_basemem:
191 196
  * Install .text and .data into high memory
192 197
  *
193 198
  * Parameters:
199
+ *   %esi : start offset within loaded image (must be a multiple of 16)
194 200
  *   %es:edi : address in high memory
195 201
  * Returns:
196
- *   none
202
+ *   %esi : end offset within image (rounded up to next multiple of 16)
197 203
  * Corrupts:
198 204
  *   none
199 205
  ****************************************************************************
@@ -205,13 +211,11 @@ install_basemem:
205 211
 	.code16
206 212
 install_highmem:
207 213
 	/* Preserve registers */
208
-	pushl	%esi
209 214
 	pushl	%edi
210 215
 	pushl	%ecx
211 216
 	pushl	%edx
212 217
 		
213 218
 	/* Install .text and .data to specified address */
214
-	movl	$_textdata_load_offset, %esi
215 219
 	movl	$_textdata_progbits_size, %ecx
216 220
 	movl	$_textdata_size, %edx
217 221
 	call	install_block
@@ -220,7 +224,6 @@ install_highmem:
220 224
 	popl	%edx
221 225
 	popl	%ecx
222 226
 	popl	%edi
223
-	popl	%esi
224 227
 	ret
225 228
 	.size install_highmem, . - install_highmem
226 229
 	
@@ -343,7 +346,10 @@ install:
343 346
 	.size install, . - install
344 347
 	.globl install_prealloc
345 348
 install_prealloc:
349
+	/* Save registers */
350
+	pushl	%esi
346 351
 	/* Install .text16 and .data16 */
352
+	movl	$_payload_offset, %esi
347 353
 	call	install_basemem
348 354
 
349 355
 #ifdef KEEP_IT_REAL
@@ -358,14 +364,13 @@ install_prealloc:
358 364
 	pushfw
359 365
 	pushw	%ds
360 366
 	pushw	%es
361
-	pushl	%esi
362 367
 	pushl	%ecx
363 368
 	cli
364 369
 
365 370
 	/* Load up %ds and %es, and set up vectors for far calls to .text16 */
366 371
 	movw	%bx, %ds
367
-	xorw	%si, %si
368
-	movw	%si, %es
372
+	xorw	%cx, %cx
373
+	movw	%cx, %es
369 374
 	movw	%ax, (init_librm_vector+2)
370 375
 	movw	%ax, (prot_call_vector+2)
371 376
 	
@@ -401,11 +406,11 @@ install_prealloc:
401 406
 
402 407
 	/* Restore registers and interrupt status */
403 408
 	popl	%ecx
404
-	popl	%esi
405 409
 	popw	%es
406 410
 	popw	%ds
407 411
 	popfw
408 412
 #endif
413
+	popl	%esi
409 414
 	ret
410 415
 	.size install_prealloc, . - install_prealloc
411 416
 

+ 2
- 0
src/arch/i386/scripts/i386.lds Прегледај датотеку

@@ -215,6 +215,8 @@ SECTIONS {
215 215
 
216 216
     _load_size		    = . - _load_addr;
217 217
 
218
+    _payload_offset	    = _text16_load_offset;
219
+
218 220
     /*
219 221
      * Alignment checks.  ALIGN() can only operate on the location
220 222
      * counter, so we set the location counter to each value we want

Loading…
Откажи
Сачувај