main.c revision 113038
1/*- 2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 3 * Copyright (c) 1998,2000 Doug Rabson <dfr@freebsd.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> 29__FBSDID("$FreeBSD: head/sys/boot/ia64/ski/main.c 113038 2003-04-03 21:36:33Z obrien $"); 30 31#include <stand.h> 32#include <string.h> 33#include <setjmp.h> 34#include <machine/fpu.h> 35 36#include "bootstrap.h" 37#include "libski.h" 38 39extern char bootprog_name[]; 40extern char bootprog_rev[]; 41extern char bootprog_date[]; 42extern char bootprog_maker[]; 43 44struct ski_devdesc currdev; /* our current device */ 45struct arch_switch archsw; /* MI/MD interface boundary */ 46 47void 48__start(void) 49{ 50 static char stack[16384] __aligned(16); 51 static char malloc[512*1024]; 52 int i; 53 54 __asm __volatile("movl gp=__gp;;"); 55 __asm __volatile("mov sp=%0" :: "r"(&stack[16384])); 56 __asm __volatile("bsw.1;;"); 57 __asm __volatile("mov ar.fpsr=%0" :: "r"(IA64_FPSR_DEFAULT)); 58 59 /* 60 * initialise the heap as early as possible. Once this is done, 61 * alloc() is usable. The stack is buried inside us, so this is 62 * safe. 63 */ 64 setheap((void *)malloc, (void *)(malloc + 512*1024)); 65 66 /* 67 * XXX Chicken-and-egg problem; we want to have console output 68 * early, but some console attributes may depend on reading from 69 * eg. the boot device, which we can't do yet. We can use 70 * printf() etc. once this is done. 71 */ 72 cons_probe(); 73 74 /* 75 * Initialise the block cache 76 */ 77 bcache_init(32, 512); /* 16k XXX tune this */ 78 79 /* 80 * March through the device switch probing for things. 81 */ 82 for (i = 0; devsw[i] != NULL; i++) 83 if (devsw[i]->dv_init != NULL) 84 (devsw[i]->dv_init)(); 85 86 printf("\n"); 87 printf("%s, Revision %s\n", bootprog_name, bootprog_rev); 88 printf("(%s, %s)\n", bootprog_maker, bootprog_date); 89#if 0 90 printf("Memory: %ld k\n", memsize() / 1024); 91#endif 92 93 /* XXX presumes that biosdisk is first in devsw */ 94 currdev.d_dev = devsw[0]; 95 currdev.d_type = currdev.d_dev->dv_type; 96 currdev.d_kind.skidisk.unit = 0; 97 /* XXX should be able to detect this, default to autoprobe */ 98 currdev.d_kind.skidisk.slice = -1; 99 /* default to 'a' */ 100 currdev.d_kind.skidisk.partition = 0; 101 102#if 0 103 /* Create arc-specific variables */ 104 bootfile = GetEnvironmentVariable(ARCENV_BOOTFILE); 105 if (bootfile) 106 setenv("bootfile", bootfile, 1); 107#endif 108 109 env_setenv("currdev", EV_VOLATILE, ski_fmtdev(&currdev), 110 ski_setcurrdev, env_nounset); 111 env_setenv("loaddev", EV_VOLATILE, ski_fmtdev(&currdev), env_noset, 112 env_nounset); 113 114 setenv("LINES", "24", 1); /* optional */ 115 116 archsw.arch_autoload = ski_autoload; 117 archsw.arch_getdev = ski_getdev; 118 archsw.arch_copyin = ski_copyin; 119 archsw.arch_copyout = ski_copyout; 120 archsw.arch_readin = ski_readin; 121 122 interact(); /* doesn't return */ 123 124 exit(0); 125} 126 127COMMAND_SET(quit, "quit", "exit the loader", command_quit); 128 129static int 130command_quit(int argc, char *argv[]) 131{ 132 exit(0); 133 return (CMD_OK); 134} 135