Browse Source

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 years ago
parent
commit
ab859a5355
2 changed files with 23 additions and 16 deletions
  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 View File

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

+ 2
- 0
src/arch/i386/scripts/i386.lds View File

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

Loading…
Cancel
Save