mirror of https://github.com/ipxe/ipxe.git
[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.pull/1/head
parent
4815188dfc
commit
82baea0a4b
|
@ -144,6 +144,7 @@ init:
|
||||||
popw %ds
|
popw %ds
|
||||||
pushw $0x40
|
pushw $0x40
|
||||||
popw %fs
|
popw %fs
|
||||||
|
|
||||||
/* Shuffle some registers around. We need %di available for
|
/* Shuffle some registers around. We need %di available for
|
||||||
* the print_xxx functions, and in a register that's
|
* the print_xxx functions, and in a register that's
|
||||||
* addressable from %es, so shuffle as follows:
|
* addressable from %es, so shuffle as follows:
|
||||||
|
@ -153,21 +154,53 @@ init:
|
||||||
*/
|
*/
|
||||||
movw %bx, %gs
|
movw %bx, %gs
|
||||||
movw %di, %bx
|
movw %di, %bx
|
||||||
|
|
||||||
/* Print message as early as possible */
|
/* Print message as early as possible */
|
||||||
movw $init_message, %si
|
movw $init_message, %si
|
||||||
xorw %di, %di
|
xorw %di, %di
|
||||||
call print_message
|
call print_message
|
||||||
call print_pci_busdevfn
|
call print_pci_busdevfn
|
||||||
|
|
||||||
/* Fill in product name string, if possible */
|
/* Fill in product name string, if possible */
|
||||||
movw $prodstr_pci_id, %di
|
movw $prodstr_pci_id, %di
|
||||||
call print_pci_busdevfn
|
call print_pci_busdevfn
|
||||||
movb $' ', prodstr_separator
|
movb $' ', prodstr_separator
|
||||||
|
|
||||||
/* Print segment address */
|
/* Print segment address */
|
||||||
movb $' ', %al
|
movb $' ', %al
|
||||||
xorw %di, %di
|
xorw %di, %di
|
||||||
call print_character
|
call print_character
|
||||||
movw %cs, %ax
|
movw %cs, %ax
|
||||||
call print_hex_word
|
call print_hex_word
|
||||||
|
|
||||||
|
/* Check for PCI BIOS version */
|
||||||
|
pushl %ebx
|
||||||
|
pushl %edx
|
||||||
|
stc
|
||||||
|
movw $0xb101, %ax
|
||||||
|
int $0x1a
|
||||||
|
jc 1f
|
||||||
|
cmpl $PCI_SIGNATURE, %edx
|
||||||
|
jne 1f
|
||||||
|
testb %ah, %ah
|
||||||
|
jnz 1f
|
||||||
|
movw $init_message_pci, %si
|
||||||
|
xorw %di, %di
|
||||||
|
call print_message
|
||||||
|
movb %bh, %al
|
||||||
|
call print_hex_nibble
|
||||||
|
movb $'.', %al
|
||||||
|
call print_character
|
||||||
|
movb %bl, %al
|
||||||
|
call print_hex_byte
|
||||||
|
cmpb $3, %bh
|
||||||
|
jae 2f
|
||||||
|
1: /* PCI <3.0: set %gs (runtime segment) = %cs (init-time segment) */
|
||||||
|
pushw %cs
|
||||||
|
popw %gs
|
||||||
|
2: popl %edx
|
||||||
|
popl %ebx
|
||||||
|
|
||||||
/* Check for PnP BIOS */
|
/* Check for PnP BIOS */
|
||||||
testw $0x0f, %bx /* PnP signature must be aligned - bochs */
|
testw $0x0f, %bx /* PnP signature must be aligned - bochs */
|
||||||
jnz hook_int19 /* uses unalignment to indicate 'fake' PnP. */
|
jnz hook_int19 /* uses unalignment to indicate 'fake' PnP. */
|
||||||
|
@ -177,6 +210,7 @@ init:
|
||||||
movw $init_message_pnp, %si
|
movw $init_message_pnp, %si
|
||||||
xorw %di, %di
|
xorw %di, %di
|
||||||
call print_message
|
call print_message
|
||||||
|
|
||||||
/* Check for BBS */
|
/* Check for BBS */
|
||||||
pushw %es:0x1b(%bx) /* Real-mode data segment */
|
pushw %es:0x1b(%bx) /* Real-mode data segment */
|
||||||
pushw %ds /* &(bbs_version) */
|
pushw %ds /* &(bbs_version) */
|
||||||
|
@ -199,10 +233,11 @@ hook_int19:
|
||||||
movw %ax, %es
|
movw %ax, %es
|
||||||
pushl %es:( 0x19 * 4 )
|
pushl %es:( 0x19 * 4 )
|
||||||
popl orig_int19
|
popl orig_int19
|
||||||
pushw %cs
|
pushw %gs /* %gs contains runtime %cs */
|
||||||
pushw $int19_entry
|
pushw $int19_entry
|
||||||
popl %es:( 0x19 * 4 )
|
popl %es:( 0x19 * 4 )
|
||||||
hook_bbs:
|
hook_bbs:
|
||||||
|
|
||||||
/* Check for PMM */
|
/* Check for PMM */
|
||||||
movw $( 0xe000 - 1 ), %bx
|
movw $( 0xe000 - 1 ), %bx
|
||||||
pmm_scan:
|
pmm_scan:
|
||||||
|
@ -259,29 +294,11 @@ gotpmm: /* PMM allocation succeeded: copy ROM to PMM block */
|
||||||
subb %bl, checksum
|
subb %bl, checksum
|
||||||
popal
|
popal
|
||||||
no_pmm:
|
no_pmm:
|
||||||
/* Check for PCI BIOS */
|
|
||||||
pushl %edx
|
/* Copy self to option ROM space. Required for PCI3.0, which
|
||||||
stc
|
* loads us to a temporary location in low memory. Will be a
|
||||||
movw $0xb101, %ax
|
* no-op for lower PCI versions.
|
||||||
int $0x1a
|
*/
|
||||||
jc no_pci
|
|
||||||
cmpl $PCI_SIGNATURE, %edx
|
|
||||||
popl %edx
|
|
||||||
jne no_pci
|
|
||||||
testb %ah, %ah
|
|
||||||
jnz no_pci
|
|
||||||
movw $init_message_pci, %si
|
|
||||||
xorw %di, %di
|
|
||||||
call print_message
|
|
||||||
movb %bh, %al
|
|
||||||
call print_hex_nibble
|
|
||||||
movb $'.', %al
|
|
||||||
call print_character
|
|
||||||
movb %bl, %al
|
|
||||||
call print_hex_byte
|
|
||||||
cmpb $3, %bh
|
|
||||||
jb no_pci3
|
|
||||||
/* Copy self to option ROM space (required for PCI3.0) */
|
|
||||||
movb $' ', %al
|
movb $' ', %al
|
||||||
xorw %di, %di
|
xorw %di, %di
|
||||||
call print_character
|
call print_character
|
||||||
|
@ -293,8 +310,7 @@ no_pmm:
|
||||||
xorw %si, %si
|
xorw %si, %si
|
||||||
xorw %di, %di
|
xorw %di, %di
|
||||||
cs rep movsb
|
cs rep movsb
|
||||||
no_pci3:
|
|
||||||
no_pci:
|
|
||||||
/* Prompt for POST-time shell */
|
/* Prompt for POST-time shell */
|
||||||
movw $init_message_prompt, %si
|
movw $init_message_prompt, %si
|
||||||
xorw %di, %di
|
xorw %di, %di
|
||||||
|
@ -338,16 +354,19 @@ wait_for_key:
|
||||||
pushw %cs
|
pushw %cs
|
||||||
call exec
|
call exec
|
||||||
no_key_pressed:
|
no_key_pressed:
|
||||||
|
|
||||||
/* Print blank lines to terminate messages */
|
/* Print blank lines to terminate messages */
|
||||||
movw $init_message_end, %si
|
movw $init_message_end, %si
|
||||||
xorw %di, %di
|
xorw %di, %di
|
||||||
call print_message
|
call print_message
|
||||||
|
|
||||||
/* Restore registers */
|
/* Restore registers */
|
||||||
popw %gs
|
popw %gs
|
||||||
popw %fs
|
popw %fs
|
||||||
popw %es
|
popw %es
|
||||||
popw %ds
|
popw %ds
|
||||||
popaw
|
popaw
|
||||||
|
|
||||||
/* Indicate boot capability to PnP BIOS, if present */
|
/* Indicate boot capability to PnP BIOS, if present */
|
||||||
movw $0x20, %ax
|
movw $0x20, %ax
|
||||||
lret
|
lret
|
||||||
|
|
Loading…
Reference in New Issue