Sfoglia il codice sorgente

[romprefix] On a PCI3.0, non-BBS system, use the correct %cs for INT19

On a system that doesn't support BBS, we end up hooking INT19 to gain
control of the boot process.  If the system is PCI3.0, we must take
care to use the runtime value for %cs, rather than the POST-time
value, otherwise we end up pointing INT19 to the temporary option ROM
POST scratch area.
tags/v0.9.4
Michael Brown 16 anni fa
parent
commit
82baea0a4b
1 ha cambiato i file con 45 aggiunte e 26 eliminazioni
  1. 45
    26
      src/arch/i386/prefix/romprefix.S

+ 45
- 26
src/arch/i386/prefix/romprefix.S Vedi File

144
 	popw	%ds
144
 	popw	%ds
145
 	pushw	$0x40
145
 	pushw	$0x40
146
 	popw	%fs
146
 	popw	%fs
147
+
147
 	/* Shuffle some registers around.  We need %di available for
148
 	/* Shuffle some registers around.  We need %di available for
148
 	 * the print_xxx functions, and in a register that's
149
 	 * the print_xxx functions, and in a register that's
149
 	 * addressable from %es, so shuffle as follows:
150
 	 * addressable from %es, so shuffle as follows:
153
 	 */
154
 	 */
154
 	movw	%bx, %gs
155
 	movw	%bx, %gs
155
 	movw	%di, %bx
156
 	movw	%di, %bx
157
+
156
 	/* Print message as early as possible */
158
 	/* Print message as early as possible */
157
 	movw	$init_message, %si
159
 	movw	$init_message, %si
158
 	xorw	%di, %di
160
 	xorw	%di, %di
159
 	call	print_message
161
 	call	print_message
160
 	call	print_pci_busdevfn
162
 	call	print_pci_busdevfn
163
+
161
 	/* Fill in product name string, if possible */
164
 	/* Fill in product name string, if possible */
162
 	movw	$prodstr_pci_id, %di
165
 	movw	$prodstr_pci_id, %di
163
 	call	print_pci_busdevfn
166
 	call	print_pci_busdevfn
164
 	movb	$' ', prodstr_separator
167
 	movb	$' ', prodstr_separator
168
+
165
 	/* Print segment address */
169
 	/* Print segment address */
166
 	movb	$' ', %al
170
 	movb	$' ', %al
167
 	xorw	%di, %di
171
 	xorw	%di, %di
168
 	call	print_character
172
 	call	print_character
169
 	movw	%cs, %ax
173
 	movw	%cs, %ax
170
 	call	print_hex_word
174
 	call	print_hex_word
175
+
176
+	/* Check for PCI BIOS version */
177
+	pushl	%ebx
178
+	pushl	%edx
179
+	stc
180
+	movw	$0xb101, %ax
181
+	int	$0x1a
182
+	jc	1f
183
+	cmpl	$PCI_SIGNATURE, %edx
184
+	jne	1f
185
+	testb	%ah, %ah
186
+	jnz	1f
187
+	movw	$init_message_pci, %si
188
+	xorw	%di, %di
189
+	call	print_message
190
+	movb	%bh, %al
191
+	call	print_hex_nibble
192
+	movb	$'.', %al
193
+	call	print_character
194
+	movb	%bl, %al
195
+	call	print_hex_byte
196
+	cmpb	$3, %bh
197
+	jae	2f
198
+1:	/* PCI <3.0: set %gs (runtime segment) = %cs (init-time segment) */
199
+	pushw	%cs
200
+	popw	%gs
201
+2:	popl	%edx
202
+	popl	%ebx
203
+
171
 	/* Check for PnP BIOS */
204
 	/* Check for PnP BIOS */
172
 	testw	$0x0f, %bx	/* PnP signature must be aligned - bochs    */
205
 	testw	$0x0f, %bx	/* PnP signature must be aligned - bochs    */
173
 	jnz	hook_int19	/* uses unalignment to indicate 'fake' PnP. */
206
 	jnz	hook_int19	/* uses unalignment to indicate 'fake' PnP. */
177
 	movw	$init_message_pnp, %si
210
 	movw	$init_message_pnp, %si
178
 	xorw	%di, %di
211
 	xorw	%di, %di
179
 	call	print_message
212
 	call	print_message
213
+
180
 	/* Check for BBS */
214
 	/* Check for BBS */
181
 	pushw	%es:0x1b(%bx)	/* Real-mode data segment */
215
 	pushw	%es:0x1b(%bx)	/* Real-mode data segment */
182
 	pushw	%ds		/* &(bbs_version) */
216
 	pushw	%ds		/* &(bbs_version) */
199
 	movw	%ax, %es
233
 	movw	%ax, %es
200
 	pushl	%es:( 0x19 * 4 )
234
 	pushl	%es:( 0x19 * 4 )
201
 	popl	orig_int19
235
 	popl	orig_int19
202
-	pushw	%cs
236
+	pushw	%gs /* %gs contains runtime %cs */
203
 	pushw	$int19_entry
237
 	pushw	$int19_entry
204
 	popl	%es:( 0x19 * 4 )
238
 	popl	%es:( 0x19 * 4 )
205
 hook_bbs:
239
 hook_bbs:
240
+
206
 	/* Check for PMM */
241
 	/* Check for PMM */
207
 	movw	$( 0xe000 - 1 ), %bx
242
 	movw	$( 0xe000 - 1 ), %bx
208
 pmm_scan:
243
 pmm_scan:
259
 	subb	%bl, checksum
294
 	subb	%bl, checksum
260
 	popal
295
 	popal
261
 no_pmm:
296
 no_pmm:
262
-	/* Check for PCI BIOS */
263
-	pushl	%edx
264
-	stc
265
-	movw	$0xb101, %ax
266
-	int	$0x1a
267
-	jc	no_pci
268
-	cmpl	$PCI_SIGNATURE, %edx
269
-	popl	%edx
270
-	jne	no_pci
271
-	testb	%ah, %ah
272
-	jnz	no_pci
273
-	movw	$init_message_pci, %si
274
-	xorw	%di, %di
275
-	call	print_message
276
-	movb	%bh, %al
277
-	call	print_hex_nibble
278
-	movb	$'.', %al
279
-	call	print_character
280
-	movb	%bl, %al
281
-	call	print_hex_byte
282
-	cmpb	$3, %bh
283
-	jb	no_pci3
284
-	/* Copy self to option ROM space (required for PCI3.0) */
297
+
298
+	/* Copy self to option ROM space.  Required for PCI3.0, which
299
+	 * loads us to a temporary location in low memory.  Will be a
300
+	 * no-op for lower PCI versions.
301
+	 */
285
 	movb	$' ', %al
302
 	movb	$' ', %al
286
 	xorw	%di, %di
303
 	xorw	%di, %di
287
 	call	print_character
304
 	call	print_character
293
 	xorw	%si, %si
310
 	xorw	%si, %si
294
 	xorw	%di, %di
311
 	xorw	%di, %di
295
 	cs rep	movsb
312
 	cs rep	movsb
296
-no_pci3:
297
-no_pci:
313
+
298
 	/* Prompt for POST-time shell */
314
 	/* Prompt for POST-time shell */
299
 	movw	$init_message_prompt, %si
315
 	movw	$init_message_prompt, %si
300
 	xorw	%di, %di
316
 	xorw	%di, %di
338
 	pushw	%cs
354
 	pushw	%cs
339
 	call	exec
355
 	call	exec
340
 no_key_pressed:
356
 no_key_pressed:
357
+
341
 	/* Print blank lines to terminate messages */
358
 	/* Print blank lines to terminate messages */
342
 	movw	$init_message_end, %si
359
 	movw	$init_message_end, %si
343
 	xorw	%di, %di
360
 	xorw	%di, %di
344
 	call	print_message
361
 	call	print_message
362
+
345
 	/* Restore registers */
363
 	/* Restore registers */
346
 	popw	%gs
364
 	popw	%gs
347
 	popw	%fs
365
 	popw	%fs
348
 	popw	%es
366
 	popw	%es
349
 	popw	%ds
367
 	popw	%ds
350
 	popaw
368
 	popaw
369
+
351
 	/* Indicate boot capability to PnP BIOS, if present */
370
 	/* Indicate boot capability to PnP BIOS, if present */
352
 	movw	$0x20, %ax
371
 	movw	$0x20, %ax
353
 	lret
372
 	lret

Loading…
Annulla
Salva