bootinfo32.c (39730) | bootinfo32.c (39902) |
---|---|
1/*- 2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $Id: bootinfo.c,v 1.4 1998/09/17 23:52:09 msmith Exp $ | 26 * $Id: bootinfo.c,v 1.5 1998/09/28 21:59:21 peter Exp $ |
27 */ 28 | 27 */ 28 |
29#include <sys/reboot.h> | |
30#include <stand.h> | 29#include <stand.h> |
30#include <sys/param.h> 31#include <sys/reboot.h> 32#include <machine/bootinfo.h> |
|
31#include "bootstrap.h" | 33#include "bootstrap.h" |
34#include "libi386.h" 35#include "btxv86.h" |
|
32 | 36 |
37static struct bootinfo bi; |
|
33 34/* 35 * Return a 'boothowto' value corresponding to the kernel arguments in 36 * (kargs) and any relevant environment variables. 37 */ 38static struct 39{ 40 char *ev; --- 163 unchanged lines hidden (view full) --- 204 MOD_SIZE(addr, mp->m_size); 205 for (md = mp->m_metadata; md != NULL; md = md->md_next) 206 if (!(md->md_type & MODINFOMD_NOCOPY)) 207 MOD_METADATA(addr, md); 208 } 209 MOD_END(addr); 210 return(addr); 211} | 38 39/* 40 * Return a 'boothowto' value corresponding to the kernel arguments in 41 * (kargs) and any relevant environment variables. 42 */ 43static struct 44{ 45 char *ev; --- 163 unchanged lines hidden (view full) --- 209 MOD_SIZE(addr, mp->m_size); 210 for (md = mp->m_metadata; md != NULL; md = md->md_next) 211 if (!(md->md_type & MODINFOMD_NOCOPY)) 212 MOD_METADATA(addr, md); 213 } 214 MOD_END(addr); 215 return(addr); 216} |
217 218/* 219 * Load the information expected by an i386 kernel. 220 * 221 * - The 'boothowto' argument is constructed 222 * - The 'botdev' argument is constructed 223 * - The 'bootinfo' struct is constructed, and copied into the kernel space. 224 * - The kernel environment is copied into kernel space. 225 * - Module metadata are formatted and placed in kernel space. 226 */ 227int 228bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip) 229{ 230 struct loaded_module *xp; 231 struct i386_devdesc *rootdev; 232 vm_offset_t addr, bootinfo_addr; 233 char *rootdevname; 234 int bootdevnr; 235 u_int pad; 236 char *kernelname; 237 238 *howtop = bi_getboothowto(args); 239 240 /* 241 * Allow the environment variable 'rootdev' to override the supplied device 242 * This should perhaps go to MI code and/or have $rootdev tested/set by 243 * MI code before launching the kernel. 244 */ 245 rootdevname = getenv("rootdev"); 246 i386_getdev((void **)(&rootdev), rootdevname, NULL); 247 if (rootdev == NULL) { /* bad $rootdev/$currdev */ 248 printf("can't determine root device\n"); 249 return(EINVAL); 250 } 251 252 /* Boot from whatever the current device is */ 253 i386_getdev((void **)(&rootdev), NULL, NULL); 254 switch(rootdev->d_type) { 255 case DEVT_DISK: 256 /* pass in the BIOS device number of the current disk */ 257 bi.bi_bios_dev = bd_unit2bios(rootdev->d_kind.biosdisk.unit); 258 bootdevnr = bd_getdev(rootdev); 259 break; 260 261 default: 262 printf("aout_exec: WARNING - don't know how to boot from device type %d\n", rootdev->d_type); 263 } 264 free(rootdev); 265 *bootdevp = bootdevnr; 266 267 /* legacy bootinfo structure */ 268 bi.bi_version = BOOTINFO_VERSION; 269 bi.bi_kernelname = 0; /* XXX char * -> kernel name */ 270 bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */ 271 bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */ 272 /* bi.bi_bios_geom[] */ 273 bi.bi_size = sizeof(bi); 274 bi.bi_memsizes_valid = 1; 275 bi.bi_vesa = 0; /* XXX correct value? */ 276 bi.bi_basemem = getbasemem(); 277 bi.bi_extmem = getextmem(); 278 279 /* find the last module in the chain */ 280 for (xp = mod_findmodule(NULL, NULL); xp->m_next != NULL; xp = xp->m_next) 281 ; 282 addr = xp->m_addr + xp->m_size; 283 /* pad to a page boundary */ 284 pad = (u_int)addr & PAGE_MASK; 285 if (pad != 0) { 286 pad = PAGE_SIZE - pad; 287 addr += pad; 288 } 289 290 /* copy our environment */ 291 bi.bi_envp = addr; 292 addr = bi_copyenv(addr); 293 294 /* pad to a page boundary */ 295 pad = (u_int)addr & PAGE_MASK; 296 if (pad != 0) { 297 pad = PAGE_SIZE - pad; 298 addr += pad; 299 } 300 /* copy module list and metadata */ 301 bi.bi_modulep = addr; 302 addr = bi_copymodules(addr); 303 304 /* all done copying stuff in, save end of loaded object space */ 305 bi.bi_kernend = addr; 306 307 *howtop |= RB_BOOTINFO; /* it's there now */ 308 309 kernelname = getenv("kernelname"); 310 bi.bi_kernelname = VTOP(kernelname); 311 *bip = VTOP(&bi); 312 313 return(0); 314} 315 |
|