module: Allow .c32 files to execute themselves
[syslinux.git] / core / init.inc
blob5cb8e49ae18a7567a93a94a7b04984838ce937dc
1 ; -*- fundamental -*-
2 ; -----------------------------------------------------------------------
4 ;   Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
5 ;   Copyright 2009 Intel Corporation; author: H. Peter Anvin
7 ;   This program is free software; you can redistribute it and/or modify
8 ;   it under the terms of the GNU General Public License as published by
9 ;   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
10 ;   Boston MA 02111-1307, USA; either version 2 of the License, or
11 ;   (at your option) any later version; incorporated herein by reference.
13 ; -----------------------------------------------------------------------
16 ; init.inc
18 ; Common initialization code (inline)
21                 section .text16
22 common_init:
23                 ; Initialize PM invocation framework
24                 call pm_init
26 %if IS_PXELINUX
27                 ; Save derivative-specific data
28                 pm_call pm_save_data
29 %endif
31                 ; Decompress PM code to its target location
32                 pm_call pm_decompress
33                 cmp eax,__pm_code_len
34                 jne kaboom
36                 extern init
37                 pm_call init
40 ; Set up the COMBOOT APIs
42                 call comboot_setup_api
44                 section .text16
46 ; The code to decompress the PM code and initialize other segments.
48                 extern _lzo1x_decompress_asm_fast
50                 section .textnr
51                 bits 32
52 pm_decompress:
53                 push 0                          ; Space for decompressed size
54                 push esp                        ; Pointer to previous word
55                 push __pm_code_start            ; Target address
56                 push dword [lzo_data_size]      ; Compressed size
57                 push dword __pm_code_lma
58                 call _lzo1x_decompress_asm_fast
59                 add esp,16
60                 pop RM_EAX                      ; Decompressed size
62                 ; Zero bss sections (but not .earlybss, since it may
63                 ; contain already-live data.)
64                 xor eax,eax
65                 mov edi,__bss_start
66                 mov ecx,__bss_dwords
67                 rep stosd
68                 mov edi,__bss16_start
69                 mov ecx,__bss16_dwords
70                 rep stosd
71                 mov edi,__high_clear_start      ; .uibss, .lowmem
72                 mov ecx,__high_clear_dwords
73                 rep stosd
75                 ret
77                 section .data16
78 lzo_data_size   dd 0                            ; filled in by compressor
80                 section .text16
81                 bits 16