1 ; -*- fundamental -*- (asm-mode sucks)
2 ; -----------------------------------------------------------------------
4 ; Copyright 1994-2009 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., 51 Franklin St, Fifth Floor,
10 ; Boston MA 02110-1301, USA; either version 2 of the License, or
11 ; (at your option) any later version; incorporated herein by reference.
13 ; -----------------------------------------------------------------------
18 ; Common code for conventional disk-based filesystems
22 ; Some semi-configurable constants... change on your own risk.
24 NULLFILE equ 0 ; Null character == empty filename
25 NULLOFFSET equ 0 ; Position in which to look
26 retry_count equ 16 ; How patient are we with the disk?
27 %assign HIGHMEM_SLOP 0 ; Avoid this much memory near the top
28 LDLINUX_MAGIC equ 0x3eb202fe ; A random number to identify ourselves with
31 SECTOR_SIZE equ (1 << SECTOR_SHIFT)
34 ; The following structure is used for "virtual kernels"; i.e. LILO-style
35 ; option labels. The options we permit here are `kernel' and `append
36 ; Since there is no room in the bottom 64K for all of these, we
37 ; stick them in high memory and copy them down before we need them.
40 vk_vname: resb FILENAME_MAX ; Virtual name **MUST BE FIRST!**
41 vk_rname: resb FILENAME_MAX ; Real name
43 vk_type: resb 1 ; Type of file
45 vk_append: resb max_cmd_len+1 ; Command line
47 vk_end: equ $ ; Should be <= vk_size
52 ; ---------------------------------------------------------------------------
54 ; ---------------------------------------------------------------------------
57 ; Memory below this point is reserved for the BIOS and the MBR
62 trackbuf resb trackbufsize ; Track buffer goes here
66 ; Common bootstrap code for disk-based derivatives
68 %include "diskstart.inc"
72 ; Now, everything is "up and running"... patch kaboom for more
73 ; verbosity and using the full screen system
84 ; Now we're all set to start with our *real* business. First load the
85 ; configuration file (if any) and parse it.
87 ; In previous versions I avoided using 32-bit registers because of a
88 ; rumour some BIOSes clobbered the upper half of 32-bit registers at
89 ; random. I figure, though, that if there are any of those still left
90 ; they probably won't be trying to install Linux on them...
92 ; The code is still ripe with 16-bitisms, though. Not worth the hassle
93 ; to take'm out. In fact, we may want to put them back if we're going
94 ; to boot ELKS at some point.
98 ; Load configuration file
100 pm_call pm_load_config
104 ; Now we have the config file open. Parse the config file and
105 ; run the user interface.
111 ; kaboom2: once everything is loaded, replace the part of kaboom
112 ; starting with "kaboom.patch" with this part
115 mov si,err_bootfailed
117 cmp byte [kaboom.again+1],18h ; INT 18h version?
121 int 19h ; And try once more to boot...
122 .norge: jmp short .norge ; If int 19h returned; this is the end
126 .noreg: jmp short .noreg ; Nynorsk
128 ; -----------------------------------------------------------------------------
130 ; -----------------------------------------------------------------------------
132 %include "common.inc" ; Universal modules
133 %include "plaincon.inc" ; writechr
134 %include "writestr.inc" ; String output
135 %include "writehex.inc" ; Hexadecimal output
136 %include "localboot.inc" ; Disk-based local boot
138 ; -----------------------------------------------------------------------------
140 ; -----------------------------------------------------------------------------
143 copyright_str db ' Copyright (C) 1994-'
145 db ' H. Peter Anvin et al', CR, LF, 0
146 err_bootfailed db CR, LF, 'Boot failed: please change disks and press '
147 db 'a key to continue.', CR, LF, 0
150 ; Config file keyword table
152 %include "keywords.inc"
155 ; Extensions to search for (in *forward* order).
158 exten_table: db '.cbt' ; COMBOOT (specific)
160 db '.bss' ; Boot sector (add superblock)
162 db '.bs', 0 ; Boot sector
163 db '.com' ; COMBOOT (same as DOS)
166 dd 0, 0 ; Need 8 null bytes here
169 ; Misc initialized (data) variables
171 %ifdef debug ; This code for debugging only
172 debug_magic dw 0D00Dh ; Debug code sentinel