summaryrefslogtreecommitdiff
path: root/core/init.inc
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-05-20 02:15:01 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-05-20 02:24:36 -0700
commit0d82b71304d596d80f3c4520f9dcf90048ca50b7 (patch)
tree75cc3186d38587e67a34836984004f3f3e3ddb7e /core/init.inc
parentf1aa00224b23e2b4c71f204c1417c7b6e5ea8e51 (diff)
downloadsyslinux-0d82b71304d596d80f3c4520f9dcf90048ca50b7.tar.gz
core: LZO compress the PM part of the core
Use LZO to compress the PM part of the core. LZO is not the best compression algorithm, but it is very fast, and the decompressor is only 447 bytes long. The LZO code is part of the LZO 2.03 library. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'core/init.inc')
-rw-r--r--core/init.inc72
1 files changed, 53 insertions, 19 deletions
diff --git a/core/init.inc b/core/init.inc
index 7f65ffa6..5d59af10 100644
--- a/core/init.inc
+++ b/core/init.inc
@@ -23,25 +23,10 @@ common_init:
; Initialize PM invocation framework
call pm_init
- ; Copy PM code to its target location
- mov esi,__pm_code_lma
- mov edi,__pm_code_start
- mov ecx,__pm_code_len
- call bcopy
- or esi,-1 ; bzero
- mov edi,__bss_start
- mov ecx,__bss_len
- call bcopy
-
- ; Zero bss sections (but not .earlybss, since it may
- ; contain already-live data.)
- xor eax,eax
- mov di,__bss16_start
- mov cx,__bss16_dwords
- rep stosd
- mov di,__uibss_start
- mov cx,__uibss_dwords
- rep stosd
+ ; Decompress PM code to its target location
+ pm_call pm_decompress
+ cmp ecx,__pm_code_len
+ jne kaboom
;
; Initialize configuration information
@@ -70,3 +55,52 @@ common_init:
; Now set up screen parameters
;
call adjust_screen
+
+;
+; The code to decompress the PM code. We copy it temporarily to 1 MB;
+; we will probably eventually actually simply run the PM code out of
+; high memory, at which point the extra copy can be dropped.
+;
+ extern _lzo1x_decompress_asm_fast
+ extern __uibss_auxseg_dwords
+
+ section .textnr
+ bits 32
+pm_decompress:
+ mov esi,__pm_code_lma
+ mov edi,0x100000
+ mov ecx,[lzo_data_size]
+ call pm_bcopy
+
+ push 0 ; Space for decompressed size
+ push esp ; Pointer to previous word
+ push __pm_code_start ; Target address
+ push dword [lzo_data_size] ; Compressed size
+ push dword 0x100000
+ call _lzo1x_decompress_asm_fast
+ add esp,16
+
+ ; Zero bss sections (but not .earlybss, since it may
+ ; contain already-live data.)
+ xor eax,eax
+ mov edi,__bss_start
+ mov ecx,__bss_dwords
+ rep stosd
+ mov edi,__bss16_start
+ mov ecx,__bss16_dwords
+ rep stosd
+ mov edi,__uibss_start
+ mov ecx,__uibss_dwords
+ rep stosd
+ mov edi,__uibss_start
+ mov ecx,__uibss_auxseg_dwords
+ rep stosd
+
+ pop ecx ; Decompressed size
+ ret
+
+ section .data16
+lzo_data_size dd 0 ; filled in by compressor
+
+ section .text16
+ bits 16