| 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 | */ |
| 46 | /* #define BOOT_NEWBOOTLOADER 2 */ |
| 47 | |
| 48 | /* |
| 49 | * Various fixed constants that do not change |
| 50 | */ |
| 51 | |
| 52 | #define BDA_MEM 0x413 /* Free memory */ |
| 53 | #define BDA_KEYFLAGS 0x417 /* Keyboard shift-state flags */ |
| 54 | #define BDA_SCR 0x449 /* Video mode */ |
| 55 | #define BDA_POS 0x450 /* Cursor position */ |
| 56 | #define BDA_BOOT 0x472 /* Boot howto flag */ |
| 57 | #define BDA_NHRDRV 0x475 |
| 58 | #define BDA_KEYBOARD 0x496 /* BDA byte with keyboard bit */ |
| 59 | |
| 60 | /* |
| 61 | * Structural equivalences |
| 62 | */ |
| 63 | #define BOOTINFO_SIZE 0x48 /* bootinfo structure size */ |
| 64 | #define MEM_ARG_SIZE 0x18 |
| 65 | #define MEM_PAGE_SIZE 0x1000 |
| 66 | #define MEM_BTX_LDR_OFF MEM_PAGE_SIZE /* offset of btx in the loader */ |
| 67 | #define USR_ARGOFFSET (BOOTINFO_SIZE+MEM_ARG_SIZE) |
| 68 | |
| 69 | /* -------- WARNING, BOOT0 STACK BELOW MEM_BIOS_LADDR -------- */ |
| 70 | #define MEM_BIOS_LADDR 0x7c00 /* Load address (static/BIOS) */ |
| 71 | |
| 72 | /* |
| 73 | * This is the origin of boot2.bin relative to the BTX user address space |
| 74 | * (e.g. physical address would be MEM_BTX_USR+BOOT2_VORIGIN). |
| 75 | */ |
| 76 | #define BOOT2_VORIGIN 0x4000 |
| 77 | |
| 78 | /* |
| 79 | * NOTE: BOOT0_ORIGIN is extracted from this file and used in boot0/Makefile |
| 80 | * BOOT1_ORIGIN is extracted from this file and used in boot2/Makefile |
| 81 | * |
| 82 | * NOTE: boot0 has a variable space after its sector which contains |
| 83 | * the fake partition and other variables. ~128 bytes should be reserved |
| 84 | * for this variable space, but it may overlap BOOT1's data space. |
| 85 | */ |
| 86 | |
| 87 | #if !defined(BOOT_NEWBOOTLOADER) |
| 88 | |
| 89 | /************************************************************************ |
| 90 | * STANDARD BOOTLOADER ADDRESS SET * |
| 91 | ************************************************************************ |
| 92 | * |
| 93 | * |
| 94 | */ |
| 95 | |
| 96 | #define USR_ARGSPACE 0x1000 /* BTX loader / ttl argspace reserved */ |
| 97 | |
| 98 | #define BOOT0_ORIGIN 0x600 /* boot0 relocated to (512+128 bytes) */ |
| 99 | /* -------- WARNING, BOOT1 STACK BELOW BOOT1_ORIGIN ------- */ |
| 100 | #define BOOT1_ORIGIN 0x700 /* boot1 relocated to (512 bytes) */ |
| 101 | #define MEM_ARG 0x900 /* tmp arg store cdboot/pxeboot */ |
| 102 | |
| 103 | #define MEM_BTX_ESP 0x1000 /* btxldr top of stack? */ |
| 104 | #define MEM_BTX_START 0x1000 /* start of BTX memory */ |
| 105 | #define MEM_BTX_ESP0 0x1800 /* Supervisor stack */ |
| 106 | #define MEM_BTX_BUF 0x1800 /* Scratch buffer stack */ |
| 107 | #define MEM_BTX_ESP1 0x1e00 /* Link stack */ |
| 108 | #define MEM_BTX_IDT 0x1e00 /* IDT */ |
| 109 | #define MEM_BTX_TSS 0x1f98 /* TSS */ |
| 110 | #define MEM_BTX_MAP 0x2000 /* I/O bit map */ |
| 111 | #define MEM_BTX_DIR 0x4000 /* Page directory */ |
| 112 | |
| 113 | /* |
| 114 | * NOTE: page table location is hardwired in /usr/src/usr.sbin/btxld/btx.h |
| 115 | */ |
| 116 | #define MEM_BTX_TBL 0x5000 /* Page tables */ |
| 117 | #define MEM_BTX_ZEND 0x7000 /* Zero from IDT to here in btx.S */ |
| 118 | |
| 119 | /******************** 0x7c00 BIOS LOAD ADDRESS (512 bytes) **********/ |
| 120 | |
| 121 | /* |
| 122 | * NOTE: BOOT2_LOAD_BUF also determines where the btx loader and boot2.bin |
| 123 | * code are loaded, since they are all in the boot2 file. |
| 124 | */ |
| 125 | #define BOOT2_LOAD_BUF 0x8c00 /* boot1 loads boot2 */ |
| 126 | #define MEM_BTX_ORG 0x9000 /* base of BTX code */ |
| 127 | #define MEM_BTX_ENTRY 0x9010 /* BTX starts execution here */ |
| 128 | /* |
| 129 | * WARNING! The USR area may be messed around with in 16 bit code mode, |
| 130 | * data loaded should probably not cross 0xffff (e.g. boot2 loads |
| 131 | * ~8K at MEM_BTX_USR). |
| 132 | * |
| 133 | * MEM_BTX_USR is basically the segment offset BTX uses when |
| 134 | * running 'client' code. So address 0 in the client code will |
| 135 | * actually be physical address MEM_BTX_USR. |
| 136 | */ |
| 137 | #define MEM_BTX_USR 0xa000 /* base of BTX client/user memory */ |
| 138 | #define MEM_BTX_USR_ARG 0xa100 |
| 139 | |
| 140 | #elif defined(BOOT_NEWBOOTLOADER) && BOOT_NEWBOOTLOADER == 1 |
| 141 | |
| 142 | /************************************************************************ |
| 143 | * EXPERIMENTAL BOOTLOADER ADDRESS SET 1 * |
| 144 | ************************************************************************ |
| 145 | * |
| 146 | * |
| 147 | */ |
| 148 | |
| 149 | #define USR_ARGSPACE 0x1000 /* BTX loader / ttl argspace reserved */ |
| 150 | #define MEM_BTX_USR_STK 0x90000 /* (phys addr) btx client usr stack */ |
| 151 | |
| 152 | #define MEM_BTX_START 0x1000 /* (unchanged) */ |
| 153 | #define MEM_BTX_ESP0 0x1800 /* (unchanged) */ |
| 154 | #define MEM_BTX_BUF 0x1800 /* (unchanged) */ |
| 155 | #define MEM_BTX_ESP1 0x1e00 /* (unchanged) */ |
| 156 | #define MEM_BTX_IDT 0x1e00 /* (unchanged) */ |
| 157 | #define MEM_BTX_TSS 0x1f98 /* (unchanged) */ |
| 158 | #define MEM_BTX_MAP 0x2000 /* (unchanged) */ |
| 159 | #define MEM_BTX_DIR 0x4000 /* (unchanged) */ |
| 160 | #define MEM_BTX_TBL 0x5000 /* (unchanged) */ |
| 161 | #define MEM_BTX_ZEND 0x7000 /* (unchanged) */ |
| 162 | |
| 163 | #define MEM_BTX_ESP 0x7800 /* don't use 0x1000 */ |
| 164 | #define BOOT0_ORIGIN 0x7800 /* boot0 relocated */ |
| 165 | #define BOOT1_ORIGIN 0x7900 /* boot1 relocated (data only?) */ |
| 166 | #define MEM_ARG 0x7b00 /* cdboot/pxeboot disk/slice xfer */ |
| 167 | /******************** 0x7c00 BIOS LOAD ADDRESS (512 bytes) **********/ |
| 168 | |
| 169 | #define BOOT2_LOAD_BUF 0x8c00 /* (unchanged) */ |
| 170 | #define MEM_BTX_ORG 0x9000 /* (unchanged) */ |
| 171 | #define MEM_BTX_ENTRY 0x9010 /* (unchanged) */ |
| 172 | |
| 173 | #define MEM_BTX_USR 0xa000 /* (unchanged) */ |
| 174 | #define MEM_BTX_USR_ARG 0xa100 /* (unchanged) */ |
| 175 | |
| 176 | |
| 177 | #elif defined(BOOT_NEWBOOTLOADER) && BOOT_NEWBOOTLOADER == 2 |
| 178 | |
| 179 | /************************************************************************ |
| 180 | * EXPERIMENTAL BOOTLOADER ADDRESS SET 2 * |
| 181 | ************************************************************************ |
| 182 | * |
| 183 | * |
| 184 | */ |
| 185 | #define USR_ARGSPACE 0x1000 /* BTX loader / ttl argspace reserved */ |
| 186 | #define MEM_BTX_USR_STK 0x90000 /* (phys addr) btx client usr stack */ |
| 187 | |
| 188 | #define MEM_BTX_START 0x2000 /* (unchanged) */ |
| 189 | #define MEM_BTX_ESP0 0x2800 /* (unchanged) */ |
| 190 | #define MEM_BTX_BUF 0x2800 /* (unchanged) */ |
| 191 | #define MEM_BTX_ESP1 0x2e00 /* (unchanged) */ |
| 192 | #define MEM_BTX_IDT 0x2e00 /* (unchanged) */ |
| 193 | #define MEM_BTX_TSS 0x2f98 /* (unchanged) */ |
| 194 | #define MEM_BTX_MAP 0x3000 /* (unchanged) */ |
| 195 | #define MEM_BTX_DIR 0x5000 /* (unchanged) */ |
| 196 | /****** MEM_BTX_TBL (16K) SUPPORT REMOVED ***********************/ |
| 197 | #define MEM_BTX_ZEND 0x6000 /* (unchanged) */ |
| 198 | |
| 199 | #define MEM_BTX_ESP 0x7800 /* don't use 0x1000 */ |
| 200 | #define BOOT0_ORIGIN 0x7800 /* boot0 relocated */ |
| 201 | #define BOOT1_ORIGIN 0x7900 /* boot1 relocated (data only?) */ |
| 202 | #define MEM_ARG 0x7b00 /* cdboot/pxeboot disk/slice xfer */ |
| 203 | /******************** 0x7c00 BIOS LOAD ADDRESS (512 bytes) **********/ |
| 204 | |
| 205 | #define BOOT2_LOAD_BUF 0x8c00 /* (unchanged) */ |
| 206 | #define MEM_BTX_ORG 0x9000 /* (unchanged) */ |
| 207 | #define MEM_BTX_ENTRY 0x9010 /* (unchanged) */ |
| 208 | |
| 209 | #define MEM_BTX_USR 0xa000 /* base of BTX client/user memory */ |
| 210 | #define MEM_BTX_USR_ARG 0xa100 /* boot1->boot2 disk/slice xfer */ |
| 211 | |
| 212 | #else |
| 213 | |
| 214 | #error "BAD BOOT_NEWBOOTLOADER SETTING. UNSET TO GET DEFAULT" |
| 215 | |
| 216 | #endif /* BOOT_NEWBOOTLOADER */ |
| 217 | |