1 /* 2 * Copyright (c) 2004 The DragonFly Project. All rights reserved. 3 * 4 * This code is derived from software contributed to The DragonFly Project 5 * by Matthew Dillon <dillon@backplane.com> 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 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 16 * distribution. 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. 20 * 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 32 * SUCH DAMAGE. 33 * 34 * $DragonFly: src/sys/boot/pc32/bootasm.h,v 1.4 2004/07/27 19:37:15 dillon Exp $ 35 */ 36 37 /* 38 * Set the bootloader address set. 39 * 40 * UNSET - default backwards compatible boot blocks 41 * 1 - experimental move addresses above 0x1000 and hardwire the user 42 * stack. 43 * 2 - experimental move addresses abobe 0x2000 and hardwire the user 44 * stack. 45 * NOTE: some changes to the standard bootloader address set and the 46 * rest of the code are not reflected in the experimental sets 47 */ 48 /* #define BOOT_NEWBOOTLOADER 2 */ 49 50 /* 51 * Various fixed constants that do not change 52 */ 53 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 */ 60 61 /* 62 * Structural equivalences 63 */ 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) 69 70 /* -------- WARNING, BOOT0 STACK BELOW MEM_BIOS_LADDR -------- */ 71 #define MEM_BIOS_LADDR 0x7c00 /* Load address (static/BIOS) */ 72 73 /* 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). 76 * 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. 79 */ 80 #define BOOT2_VORIGIN 0x2000 81 82 /* 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 85 * 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. 89 */ 90 91 #if !defined(BOOT_NEWBOOTLOADER) 92 93 /************************************************************************ 94 * STANDARD BOOTLOADER ADDRESS SET * 95 ************************************************************************ 96 * 97 * 98 */ 99 100 #define USR_ARGSPACE 0x1000 /* BTX loader / ttl argspace reserved */ 101 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 */ 106 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 */ 116 117 /* 118 * NOTE: page table location is hardwired in /usr/src/usr.sbin/btxld/btx.h 119 */ 120 #define MEM_BTX_ZEND 0x7000 /* Zero from IDT to here in btx.S */ 121 122 /******************** 0x7c00 BIOS LOAD ADDRESS (512 bytes) **********/ 123 124 /* 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. 127 */ 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 */ 131 /* 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). 135 * 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. 139 */ 140 #define MEM_BTX_USR 0xa000 /* base of BTX client/user memory */ 141 #define MEM_BTX_USR_ARG 0xa100 142 143 /* 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 147 * out from the smap. 148 * 149 * There aren't really any other places we can put it short of intruding on 150 * the kernel/module load space. 151 */ 152 /*#define MEM_BTX_USR_STK 0x3000000*/ 153 /*#define MEM_BTX_USR_STK 0x0F0000*/ 154 155 #elif defined(BOOT_NEWBOOTLOADER) && BOOT_NEWBOOTLOADER == 1 156 157 /************************************************************************ 158 * EXPERIMENTAL BOOTLOADER ADDRESS SET 1 * 159 ************************************************************************ 160 * 161 * 162 */ 163 164 #define USR_ARGSPACE 0x1000 /* BTX loader / ttl argspace reserved */ 165 #define MEM_BTX_USR_STK 0x90000 /* (phys addr) btx client usr stack */ 166 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) */ 177 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) **********/ 183 184 #define BOOT2_LOAD_BUF 0x8c00 /* (unchanged) */ 185 #define MEM_BTX_ORG 0x9000 /* (unchanged) */ 186 #define MEM_BTX_ENTRY 0x9010 /* (unchanged) */ 187 188 #define MEM_BTX_USR 0xa000 /* (unchanged) */ 189 #define MEM_BTX_USR_ARG 0xa100 /* (unchanged) */ 190 191 192 #elif defined(BOOT_NEWBOOTLOADER) && BOOT_NEWBOOTLOADER == 2 193 194 /************************************************************************ 195 * EXPERIMENTAL BOOTLOADER ADDRESS SET 2 * 196 ************************************************************************ 197 * 198 * 199 */ 200 #define USR_ARGSPACE 0x1000 /* BTX loader / ttl argspace reserved */ 201 #define MEM_BTX_USR_STK 0x90000 /* (phys addr) btx client usr stack */ 202 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) */ 213 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) **********/ 219 220 #define BOOT2_LOAD_BUF 0x8c00 /* (unchanged) */ 221 #define MEM_BTX_ORG 0x9000 /* (unchanged) */ 222 #define MEM_BTX_ENTRY 0x9010 /* (unchanged) */ 223 224 #define MEM_BTX_USR 0xa000 /* base of BTX client/user memory */ 225 #define MEM_BTX_USR_ARG 0xa100 /* boot1->boot2 disk/slice xfer */ 226 227 #else 228 229 #error "BAD BOOT_NEWBOOTLOADER SETTING. UNSET TO GET DEFAULT" 230 231 #endif /* BOOT_NEWBOOTLOADER */ 232 233