| 1 | ; -*- fundamental -*- |
|---|
| 2 | ; ----------------------------------------------------------------------- |
|---|
| 3 | ; |
|---|
| 4 | ; Copyright 2004-2008 H. Peter Anvin - All Rights Reserved |
|---|
| 5 | ; Copyright 2009 Intel Corporation; author: H. Peter Anvin |
|---|
| 6 | ; |
|---|
| 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. |
|---|
| 12 | ; |
|---|
| 13 | ; ----------------------------------------------------------------------- |
|---|
| 14 | |
|---|
| 15 | ; |
|---|
| 16 | ; init.inc |
|---|
| 17 | ; |
|---|
| 18 | ; Common initialization code (inline) |
|---|
| 19 | ; |
|---|
| 20 | |
|---|
| 21 | section .text16 |
|---|
| 22 | common_init: |
|---|
| 23 | ; Initialize PM invocation framework |
|---|
| 24 | call pm_init |
|---|
| 25 | |
|---|
| 26 | ; Decompress PM code to its target location |
|---|
| 27 | pm_call pm_decompress |
|---|
| 28 | cmp eax,__pm_code_len |
|---|
| 29 | jne kaboom |
|---|
| 30 | |
|---|
| 31 | ; |
|---|
| 32 | ; Initialize timer |
|---|
| 33 | ; |
|---|
| 34 | call timer_init |
|---|
| 35 | |
|---|
| 36 | ; |
|---|
| 37 | ; Initialize configuration information |
|---|
| 38 | ; |
|---|
| 39 | call reset_config |
|---|
| 40 | |
|---|
| 41 | ; |
|---|
| 42 | ; Set up the COMBOOT APIs |
|---|
| 43 | ; |
|---|
| 44 | call comboot_setup_api |
|---|
| 45 | |
|---|
| 46 | ; |
|---|
| 47 | ; Now set up screen parameters |
|---|
| 48 | ; |
|---|
| 49 | call adjust_screen |
|---|
| 50 | |
|---|
| 51 | ; |
|---|
| 52 | ; CPU-dependent initialization and related checks. |
|---|
| 53 | ; |
|---|
| 54 | check_escapes: |
|---|
| 55 | mov ah,02h ; Check keyboard flags |
|---|
| 56 | int 16h |
|---|
| 57 | mov [KbdFlags],al ; Save for boot prompt check |
|---|
| 58 | test al,04h ; Ctrl->skip 386 check |
|---|
| 59 | jnz skip_checks |
|---|
| 60 | |
|---|
| 61 | ; |
|---|
| 62 | ; Now check that there is sufficient low (DOS) memory |
|---|
| 63 | ; |
|---|
| 64 | ; NOTE: Linux doesn't use all of real_mode_seg, but we use the same |
|---|
| 65 | ; segment for COMBOOT images, which can use all 64K |
|---|
| 66 | ; |
|---|
| 67 | int 12h |
|---|
| 68 | mov edx,__lowmem_heap + min_lowmem_heap + 1023 |
|---|
| 69 | shr edx,10 |
|---|
| 70 | cmp ax,dx |
|---|
| 71 | jae enough_ram |
|---|
| 72 | mov si,err_noram |
|---|
| 73 | mov cl,10 |
|---|
| 74 | push dx |
|---|
| 75 | div cl |
|---|
| 76 | add [si+err_noram.need-err_noram+2],ah |
|---|
| 77 | cbw |
|---|
| 78 | div cl |
|---|
| 79 | add [si+err_noram.need-err_noram],ax |
|---|
| 80 | pop ax |
|---|
| 81 | div cl |
|---|
| 82 | add [si+err_noram.size-err_noram+2],ah |
|---|
| 83 | cbw |
|---|
| 84 | div cl |
|---|
| 85 | add [si+err_noram.size-err_noram],ax |
|---|
| 86 | call writestr_early |
|---|
| 87 | jmp kaboom |
|---|
| 88 | enough_ram: |
|---|
| 89 | skip_checks: |
|---|
| 90 | |
|---|
| 91 | section .data16 |
|---|
| 92 | err_noram db 'It appears your computer has only ' |
|---|
| 93 | .size db '000' |
|---|
| 94 | db 'K of low ("DOS") RAM.', CR, LF |
|---|
| 95 | db 'This version of Syslinux needs ' |
|---|
| 96 | .need db '000' |
|---|
| 97 | db 'K to boot. If you get this', CR, LF |
|---|
| 98 | db 'message in error, hold down the Ctrl key while' |
|---|
| 99 | db 'booting, and I', CR, LF |
|---|
| 100 | db 'will take your word for it.', CR, LF, 0 |
|---|
| 101 | |
|---|
| 102 | section .text16 |
|---|
| 103 | ; |
|---|
| 104 | ; The code to decompress the PM code and initialize other segments. |
|---|
| 105 | ; |
|---|
| 106 | extern _lzo1x_decompress_asm_fast |
|---|
| 107 | |
|---|
| 108 | section .textnr |
|---|
| 109 | bits 32 |
|---|
| 110 | pm_decompress: |
|---|
| 111 | push 0 ; Space for decompressed size |
|---|
| 112 | push esp ; Pointer to previous word |
|---|
| 113 | push __pm_code_start ; Target address |
|---|
| 114 | push dword [lzo_data_size] ; Compressed size |
|---|
| 115 | push dword __pm_code_lma |
|---|
| 116 | call _lzo1x_decompress_asm_fast |
|---|
| 117 | add esp,16 |
|---|
| 118 | pop RM_EAX ; Decompressed size |
|---|
| 119 | |
|---|
| 120 | ; Zero bss sections (but not .earlybss, since it may |
|---|
| 121 | ; contain already-live data.) |
|---|
| 122 | xor eax,eax |
|---|
| 123 | mov edi,__bss_start |
|---|
| 124 | mov ecx,__bss_dwords |
|---|
| 125 | rep stosd |
|---|
| 126 | mov edi,__bss16_start |
|---|
| 127 | mov ecx,__bss16_dwords |
|---|
| 128 | rep stosd |
|---|
| 129 | mov edi,__high_clear_start ; .uibss, .auxseg, .lowmem |
|---|
| 130 | mov ecx,__high_clear_dwords |
|---|
| 131 | rep stosd |
|---|
| 132 | |
|---|
| 133 | ret |
|---|
| 134 | |
|---|
| 135 | section .data16 |
|---|
| 136 | lzo_data_size dd 0 ; filled in by compressor |
|---|
| 137 | |
|---|
| 138 | section .text16 |
|---|
| 139 | bits 16 |
|---|