d5d68b2e31
The option ROM header contains a one-byte field indicating the number of 512-byte sectors in the ROM image. Currently it is linked to contain the number of uncompressed sectors, with an instruction to the compressor to correct it. This causes link failure when the uncompressed size of the ROM image is over 128k. Fix by replacing the SUBx compressor fixup with an ADDx fixup that adds the total compressed output length, scaled as requested, to an addend stored in the field where the final length value will be placed. This is similar to the behavior of ELF relocations, and ensures that an overflow error will not be generated unless the compressed size is still too large for the field. This also allows us to do away with the _filesz_pgh and _filesz_sect calculations exported by the linker script. Output tested bitwise identical to the old SUBx mechanism on hd, dsk, lkrn, and rom prefixes, on both 32-bit and 64-bit processors. Modified-by: Michael Brown <mcb30@etherboot.org> Signed-off-by: Michael Brown <mcb30@etherboot.org>
110 lines
1.5 KiB
ArmAsm
110 lines
1.5 KiB
ArmAsm
FILE_LICENCE ( GPL2_OR_LATER )
|
|
|
|
.text
|
|
.arch i386
|
|
.section ".prefix", "awx", @progbits
|
|
.code16
|
|
.org 0
|
|
|
|
movw $load_image, %bp
|
|
jmp find_active_partition
|
|
|
|
#include "bootpart.S"
|
|
|
|
load_image:
|
|
/* Get disk geometry */
|
|
pushal
|
|
pushw %es
|
|
movb $0x08, %ah
|
|
int $0x13
|
|
jc load_failed
|
|
movb %cl, max_sector
|
|
movb %dh, max_head
|
|
popw %es
|
|
popal
|
|
|
|
1: /* Read to end of current track */
|
|
movb %cl, %al
|
|
negb %al
|
|
addb max_sector, %al
|
|
incb %al
|
|
andb $0x3f, %al
|
|
movzbl %al, %eax
|
|
call *read_sectors
|
|
jc load_failed
|
|
|
|
/* Update %es */
|
|
movw %es, %bx
|
|
shll $5, %eax
|
|
addw %ax, %bx
|
|
movw %bx, %es
|
|
shrl $5, %eax
|
|
|
|
/* Update LBA address */
|
|
addl %eax, %edi
|
|
adcl $0, %esi
|
|
|
|
/* Update CHS address */
|
|
andb $0xc0, %cl
|
|
orb $0x01, %cl
|
|
incb %dh
|
|
cmpb max_head, %dh
|
|
jbe 2f
|
|
xorb %dh, %dh
|
|
incb %ch
|
|
jnc 2f
|
|
addb $0xc0, %cl
|
|
2:
|
|
/* Loop until whole image is read */
|
|
subl %eax, load_length
|
|
ja 1b
|
|
ljmp $BOOT_SEG, $start_image
|
|
|
|
max_sector:
|
|
.byte 0
|
|
max_head:
|
|
.byte 0
|
|
load_length:
|
|
.long 0
|
|
|
|
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
|
|
.ascii "ADDL"
|
|
.long load_length
|
|
.long 512
|
|
.long 0
|
|
.previous
|
|
|
|
|
|
load_failed:
|
|
movw $10f, %si
|
|
jmp boot_error
|
|
10: .asciz "Could not load gPXE\r\n"
|
|
|
|
.org 510
|
|
.byte 0x55, 0xaa
|
|
|
|
start_image:
|
|
/* Install gPXE */
|
|
call install
|
|
|
|
/* Set up real-mode stack */
|
|
movw %bx, %ss
|
|
movw $_estack16, %sp
|
|
|
|
/* Jump to .text16 segment */
|
|
pushw %ax
|
|
pushw $1f
|
|
lret
|
|
.section ".text16", "awx", @progbits
|
|
1:
|
|
pushl $main
|
|
pushw %cs
|
|
call prot_call
|
|
popl %ecx /* discard */
|
|
|
|
/* Uninstall gPXE */
|
|
call uninstall
|
|
|
|
/* Boot next device */
|
|
int $0x18
|