mirror of
https://github.com/ipxe/ipxe
synced 2025-12-16 09:32:33 +03:00
Compressed ROM images now work.
This commit is contained in:
@@ -37,6 +37,9 @@
|
||||
*/
|
||||
#define HIGHMEM_LOADPOINT ( 4 << 20 )
|
||||
|
||||
/* Image compression enabled */
|
||||
#define COMPRESS 1
|
||||
|
||||
#define CR0_PE 1
|
||||
|
||||
.arch i386
|
||||
@@ -81,7 +84,11 @@ install_block:
|
||||
|
||||
/* Do the copy */
|
||||
cld
|
||||
rep addr32 movsb /* or "call decompress16" */
|
||||
#if COMPRESS
|
||||
call decompress16
|
||||
#else
|
||||
call nodecompress16
|
||||
#endif
|
||||
|
||||
/* Zero remaining space */
|
||||
movl %eax, %edi
|
||||
|
||||
18
src/arch/i386/prefix/nonrv2b.S
Normal file
18
src/arch/i386/prefix/nonrv2b.S
Normal file
@@ -0,0 +1,18 @@
|
||||
/* Placeholder for decompress16 in non-compressed images */
|
||||
|
||||
.text
|
||||
.arch i386
|
||||
.section ".prefix.lib", "ax", @progbits
|
||||
|
||||
.code16
|
||||
.globl nodecompress16
|
||||
nodecompress16:
|
||||
rep addr32 movsb
|
||||
ret
|
||||
|
||||
/* File split information for the compressor */
|
||||
.section ".zinfo", "a"
|
||||
.ascii "COPY"
|
||||
.long _prefix_load_offset
|
||||
.long _load_size
|
||||
.long _max_align
|
||||
@@ -14,7 +14,7 @@
|
||||
.org 0x00
|
||||
romheader:
|
||||
.word 0xAA55 /* BIOS extension signature */
|
||||
.byte _rom_size /* Size in 512-byte blocks */
|
||||
romheader_size: .byte _rom_size /* Size in 512-byte blocks */
|
||||
jmp init_vector /* Initialisation vector */
|
||||
.org 0x16
|
||||
.word undiheader
|
||||
@@ -34,7 +34,7 @@ pciheader:
|
||||
.byte 0x02 /* Device Base Type code */
|
||||
.byte 0x00 /* Device Sub-Type code */
|
||||
.byte 0x00 /* Device Interface Type code */
|
||||
.word _rom_size /* Image length same as offset 02h */
|
||||
pciheader_size: .word _rom_size /* Image length same as offset 02h */
|
||||
.word 0x0001 /* revision level of code/data */
|
||||
.byte 0x00 /* code type */
|
||||
.byte 0x80 /* Flags (last PCI data structure) */
|
||||
@@ -215,3 +215,15 @@ print_message:
|
||||
popw %ax
|
||||
ret
|
||||
.size print_message, . - print_message
|
||||
|
||||
|
||||
/* Data update information for the compressor */
|
||||
.section ".zinfo.fixup", "a"
|
||||
.ascii "SUBB"
|
||||
.long romheader_size
|
||||
.long 512
|
||||
.long 0
|
||||
.ascii "SUBW"
|
||||
.long pciheader_size
|
||||
.long 512
|
||||
.long 0
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
.text
|
||||
.arch i386
|
||||
.section ".prefix", "ax", @progbits
|
||||
.section ".prefix.lib", "ax", @progbits
|
||||
|
||||
#ifdef CODE16
|
||||
/****************************************************************************
|
||||
@@ -54,6 +54,7 @@
|
||||
* NOTE: It would be possible to build a smaller version of the
|
||||
* decompression code for -DKEEP_IT_REAL by using
|
||||
* #define REG(x) x
|
||||
* #define MOVSB movsb
|
||||
* to use 16-bit registers where possible. This would impose limits
|
||||
* that the compressed data size must be in the range [1,65533-%si]
|
||||
* and the uncompressed data size must be in the range [1,65536-%di]
|
||||
@@ -66,6 +67,7 @@
|
||||
*/
|
||||
|
||||
#define REG(x) e ## x
|
||||
#define MOVSB addr32 movsb
|
||||
|
||||
.code16
|
||||
.globl decompress16
|
||||
@@ -109,11 +111,10 @@ decompress:
|
||||
cld
|
||||
xor %xBP, %xBP
|
||||
dec %xBP /* last_m_off = -1 */
|
||||
add $4, %xSI /* Skip "file length" field */
|
||||
jmp dcl1_n2b
|
||||
|
||||
decompr_literals_n2b:
|
||||
movsb
|
||||
MOVSB
|
||||
decompr_loop_n2b:
|
||||
addl %ebx, %ebx
|
||||
jnz dcl2_n2b
|
||||
@@ -157,7 +158,7 @@ decompr_got_mlen_n2b:
|
||||
push %xSI
|
||||
lea (%xBP,%xDI), %xSI /* m_pos = dst + olen + -m_off */
|
||||
rep
|
||||
es movsb /* dst[olen++] = *m_pos++ while(m_len > 0) */
|
||||
es MOVSB /* dst[olen++] = *m_pos++ while(m_len > 0) */
|
||||
pop %xSI
|
||||
jmp decompr_loop_n2b
|
||||
|
||||
@@ -179,3 +180,23 @@ decompr_end_n2b:
|
||||
popl %ebx
|
||||
pop %xAX
|
||||
ret
|
||||
|
||||
|
||||
/* File split information for the compressor */
|
||||
.section ".zinfo", "a"
|
||||
.ascii "COPY"
|
||||
.long _prefix_load_offset
|
||||
.long _prefix_progbits_size
|
||||
.long _max_align
|
||||
.ascii "PACK"
|
||||
.long _text16_load_offset
|
||||
.long _text16_progbits_size
|
||||
.long _max_align
|
||||
.ascii "PACK"
|
||||
.long _data16_load_offset
|
||||
.long _data16_progbits_size
|
||||
.long _max_align
|
||||
.ascii "PACK"
|
||||
.long _textdata_load_offset
|
||||
.long _textdata_progbits_size
|
||||
.long _max_align
|
||||
|
||||
@@ -164,6 +164,24 @@ SECTIONS {
|
||||
|
||||
_end = .;
|
||||
|
||||
/*
|
||||
* Compressor information block
|
||||
*/
|
||||
|
||||
_zinfo_link_addr = 0;
|
||||
. = _zinfo_link_addr;
|
||||
_zinfo = .;
|
||||
|
||||
.zinfo : AT ( _zinfo_load_offset + __zinfo ) {
|
||||
__zinfo = .;
|
||||
_entry = .;
|
||||
*(.zinfo)
|
||||
*(.zinfo.*)
|
||||
_ezinfo_progbits = .;
|
||||
}
|
||||
|
||||
_ezinfo = .;
|
||||
|
||||
/*
|
||||
* Dispose of the comment and note sections to make the link map
|
||||
* easier to read
|
||||
@@ -215,6 +233,13 @@ SECTIONS {
|
||||
|
||||
_load_size = . - _load_addr;
|
||||
|
||||
. -= _zinfo_link_addr;
|
||||
_zinfo_load_offset = ALIGN ( _max_align );
|
||||
_zinfo_load_addr = _zinfo_link_addr + _zinfo_load_offset;
|
||||
_zinfo_size = _ezinfo - _zinfo;
|
||||
_zinfo_progbits_size = _ezinfo_progbits - _zinfo;
|
||||
. = _zinfo_load_addr + _zinfo_progbits_size;
|
||||
|
||||
_payload_offset = _text16_load_offset;
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user