movebits: add an inline to test for SMT_FREE || SMT_TERMINAL
[syslinux/sherbszt.git] / core / init.inc
blobb74cf30b73383f1b9f820a3954051dec86d0214c
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 syslinux_register_bios, init
38                 pm_call syslinux_register_bios
39                 pm_call init
42 ; Set up the COMBOOT APIs
44                 call comboot_setup_api
46                 section .text16
48 ; The code to decompress the PM code and initialize other segments.
50                 extern _lzo1x_decompress_asm_fast_safe
52                 section .textnr
53                 bits 32
54 pm_decompress:
55                 push __pm_code_len + 16         ; Space for decompressed size
56                 push esp                        ; Pointer to previous word
57                 push __pm_code_start            ; Target address
58                 push dword [lzo_data_size]      ; Compressed size
59                 push dword __pm_code_lma
60                 call _lzo1x_decompress_asm_fast_safe
61                 add esp,16
62                 pop RM_EAX                      ; Decompressed size
64                 ; Zero bss sections (but not .earlybss, since it may
65                 ; contain already-live data.)
66                 xor eax,eax
67                 mov edi,__bss_start
68                 mov ecx,__bss_dwords
69                 rep stosd
70                 mov edi,__bss16_start
71                 mov ecx,__bss16_dwords
72                 rep stosd
73                 mov edi,__high_clear_start      ; .uibss, .lowmem
74                 mov ecx,__high_clear_dwords
75                 rep stosd
77                 ret
79                 section .data16
80 lzo_data_size   dd 0                            ; filled in by compressor
82                 section .text16
83                 bits 16