2 * Copyright (c) 2004 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * $DragonFly: src/sys/boot/pc32/bootasm.h,v 1.4 2004/07/27 19:37:15 dillon Exp $
38 * Set the bootloader address set.
40 * UNSET - default backwards compatible boot blocks
41 * 1 - experimental move addresses above 0x1000 and hardwire the user
43 * 2 - experimental move addresses abobe 0x2000 and hardwire the user
45 * NOTE: some changes to the standard bootloader address set and the
46 * rest of the code are not reflected in the experimental sets
48 /* #define BOOT_NEWBOOTLOADER 2 */
51 * Various fixed constants that do not change
54 #define BDA_MEM 0x413 /* Free memory */
55 #define BDA_SCR 0x449 /* Video mode */
56 #define BDA_POS 0x450 /* Cursor position */
57 #define BDA_BOOT 0x472 /* Boot howto flag */
58 #define BDA_NHRDRV 0x475 /* Number of drivers found by BIOS */
59 #define BDA_KEYBOARD 0x496 /* BDA byte with keyboard bit */
62 * Structural equivalences
64 #define BOOTINFO_SIZE 0x48 /* bootinfo structure size */
65 #define MEM_ARG_SIZE 0x18
66 #define MEM_PAGE_SIZE 0x1000
67 #define MEM_BTX_LDR_OFF MEM_PAGE_SIZE /* offset of btx in the loader */
68 #define USR_ARGOFFSET (BOOTINFO_SIZE+MEM_ARG_SIZE)
70 /* -------- WARNING, BOOT0 STACK BELOW MEM_BIOS_LADDR -------- */
71 #define MEM_BIOS_LADDR 0x7c00 /* Load address (static/BIOS) */
74 * This is the origin of boot2.bin relative to the BTX user address space
75 * (e.g. physical address would be MEM_BTX_USR+BOOT2_VORIGIN).
77 * The physical origin is typically around 0xC000 and limits the size of
78 * boot2 to 16K, otherwise the loader will overflow the segment in v86 mode.
80 #define BOOT2_VORIGIN 0x2000
83 * NOTE: BOOT0_ORIGIN is extracted from this file and used in boot0/Makefile
84 * BOOT1_ORIGIN is extracted from this file and used in boot2/Makefile
86 * NOTE: boot0 has a variable space after its sector which contains
87 * the fake partition and other variables. ~128 bytes should be reserved
88 * for this variable space, but it may overlap BOOT1's data space.
91 #if !defined(BOOT_NEWBOOTLOADER)
93 /************************************************************************
94 * STANDARD BOOTLOADER ADDRESS SET *
95 ************************************************************************
100 #define USR_ARGSPACE 0x1000 /* BTX loader / ttl argspace reserved */
102 #define BOOT0_ORIGIN 0x600 /* boot0 relocated to (512+128 bytes) */
103 /* -------- WARNING, BOOT1 STACK BELOW BOOT1_ORIGIN ------- */
104 #define BOOT1_ORIGIN 0x700 /* boot1 relocated to (512 bytes) */
105 #define MEM_ARG 0x900 /* tmp arg store cdboot/pxeboot */
107 #define MEM_BTX_ESP 0x1000 /* btxldr top of stack? */
108 #define MEM_BTX_START 0x1000 /* start of BTX memory */
109 #define MEM_BTX_ESP0 0x1800 /* Supervisor stack */
110 #define MEM_BTX_BUF 0x1800 /* Scratch buffer stack */
111 #define MEM_BTX_ESPR 0x5e00 /* Real mode stack */
112 #define MEM_BTX_IDT 0x5e00 /* IDT */
113 #define MEM_BTX_TSS 0x5f98 /* TSS */
114 #define MEM_BTX_MAP 0x6000 /* I/O bit map */
115 #define MEM_BTX_TSS_END 0x7fff /* Start of user memory */
118 * NOTE: page table location is hardwired in /usr/src/usr.sbin/btxld/btx.h
120 #define MEM_BTX_ZEND 0x7000 /* Zero from IDT to here in btx.S */
122 /******************** 0x7c00 BIOS LOAD ADDRESS (512 bytes) **********/
125 * NOTE: BOOT2_LOAD_BUF also determines where the btx loader and boot2.bin
126 * code are loaded, since they are all in the boot2 file.
128 #define BOOT2_LOAD_BUF 0x8c00 /* boot1 loads boot2 */
129 #define MEM_BTX_ORG 0x9000 /* base of BTX code */
130 #define MEM_BTX_ENTRY 0x9010 /* BTX starts execution here */
132 * WARNING! The USR area may be messed around with in 16 bit code mode,
133 * data loaded should probably not cross 0xffff (e.g. boot2 loads
134 * ~8K at MEM_BTX_USR).
136 * MEM_BTX_USR is basically the segment offset BTX uses when
137 * running 'client' code. So address 0 in the client code will
138 * actually be physical address MEM_BTX_USR.
140 #define MEM_BTX_USR 0xa000 /* base of BTX client/user memory */
141 #define MEM_BTX_USR_ARG 0xa100
144 * By default the user stack is (theoretically) placed at the top of
145 * BIOS memory (typically around the 640K mark). See btx.S. BTX loads
146 * the stack from a BIOS memory address (BDA_MEM) rather than figuring it
149 * There aren't really any other places we can put it short of intruding on
150 * the kernel/module load space.
152 /*#define MEM_BTX_USR_STK 0x3000000*/
153 /*#define MEM_BTX_USR_STK 0x0F0000*/
155 #elif defined(BOOT_NEWBOOTLOADER) && BOOT_NEWBOOTLOADER == 1
157 /************************************************************************
158 * EXPERIMENTAL BOOTLOADER ADDRESS SET 1 *
159 ************************************************************************
164 #define USR_ARGSPACE 0x1000 /* BTX loader / ttl argspace reserved */
165 #define MEM_BTX_USR_STK 0x90000 /* (phys addr) btx client usr stack */
167 #define MEM_BTX_START 0x1000 /* (unchanged) */
168 #define MEM_BTX_ESP0 0x1800 /* (unchanged) */
169 #define MEM_BTX_BUF 0x1800 /* (unchanged) */
170 #define MEM_BTX_ESP1 0x1e00 /* (unchanged) */
171 #define MEM_BTX_IDT 0x1e00 /* (unchanged) */
172 #define MEM_BTX_TSS 0x1f98 /* (unchanged) */
173 #define MEM_BTX_MAP 0x2000 /* (unchanged) */
174 #define MEM_BTX_DIR 0x4000 /* (unchanged) */
175 #define MEM_BTX_TBL 0x5000 /* (unchanged) */
176 #define MEM_BTX_ZEND 0x7000 /* (unchanged) */
178 #define MEM_BTX_ESP 0x7800 /* don't use 0x1000 */
179 #define BOOT0_ORIGIN 0x7800 /* boot0 relocated */
180 #define BOOT1_ORIGIN 0x7900 /* boot1 relocated (data only?) */
181 #define MEM_ARG 0x7b00 /* cdboot/pxeboot disk/slice xfer */
182 /******************** 0x7c00 BIOS LOAD ADDRESS (512 bytes) **********/
184 #define BOOT2_LOAD_BUF 0x8c00 /* (unchanged) */
185 #define MEM_BTX_ORG 0x9000 /* (unchanged) */
186 #define MEM_BTX_ENTRY 0x9010 /* (unchanged) */
188 #define MEM_BTX_USR 0xa000 /* (unchanged) */
189 #define MEM_BTX_USR_ARG 0xa100 /* (unchanged) */
192 #elif defined(BOOT_NEWBOOTLOADER) && BOOT_NEWBOOTLOADER == 2
194 /************************************************************************
195 * EXPERIMENTAL BOOTLOADER ADDRESS SET 2 *
196 ************************************************************************
200 #define USR_ARGSPACE 0x1000 /* BTX loader / ttl argspace reserved */
201 #define MEM_BTX_USR_STK 0x90000 /* (phys addr) btx client usr stack */
203 #define MEM_BTX_START 0x2000 /* (unchanged) */
204 #define MEM_BTX_ESP0 0x2800 /* (unchanged) */
205 #define MEM_BTX_BUF 0x2800 /* (unchanged) */
206 #define MEM_BTX_ESP1 0x2e00 /* (unchanged) */
207 #define MEM_BTX_IDT 0x2e00 /* (unchanged) */
208 #define MEM_BTX_TSS 0x2f98 /* (unchanged) */
209 #define MEM_BTX_MAP 0x3000 /* (unchanged) */
210 #define MEM_BTX_DIR 0x5000 /* (unchanged) */
211 /****** MEM_BTX_TBL (16K) SUPPORT REMOVED ***********************/
212 #define MEM_BTX_ZEND 0x6000 /* (unchanged) */
214 #define MEM_BTX_ESP 0x7800 /* don't use 0x1000 */
215 #define BOOT0_ORIGIN 0x7800 /* boot0 relocated */
216 #define BOOT1_ORIGIN 0x7900 /* boot1 relocated (data only?) */
217 #define MEM_ARG 0x7b00 /* cdboot/pxeboot disk/slice xfer */
218 /******************** 0x7c00 BIOS LOAD ADDRESS (512 bytes) **********/
220 #define BOOT2_LOAD_BUF 0x8c00 /* (unchanged) */
221 #define MEM_BTX_ORG 0x9000 /* (unchanged) */
222 #define MEM_BTX_ENTRY 0x9010 /* (unchanged) */
224 #define MEM_BTX_USR 0xa000 /* base of BTX client/user memory */
225 #define MEM_BTX_USR_ARG 0xa100 /* boot1->boot2 disk/slice xfer */
229 #error "BAD BOOT_NEWBOOTLOADER SETTING. UNSET TO GET DEFAULT"
231 #endif /* BOOT_NEWBOOTLOADER */