main.c revision 163897
183364Sdfr/*- 283364Sdfr * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 383364Sdfr * Copyright (c) 1998,2000 Doug Rabson <dfr@freebsd.org> 483364Sdfr * All rights reserved. 583364Sdfr * 683364Sdfr * Redistribution and use in source and binary forms, with or without 783364Sdfr * modification, are permitted provided that the following conditions 883364Sdfr * are met: 983364Sdfr * 1. Redistributions of source code must retain the above copyright 1083364Sdfr * notice, this list of conditions and the following disclaimer. 1183364Sdfr * 2. Redistributions in binary form must reproduce the above copyright 1283364Sdfr * notice, this list of conditions and the following disclaimer in the 1383364Sdfr * documentation and/or other materials provided with the distribution. 1483364Sdfr * 1583364Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1683364Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1783364Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1883364Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1983364Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2083364Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2183364Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2283364Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2383364Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2483364Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2583364Sdfr * SUCH DAMAGE. 2683364Sdfr */ 2783364Sdfr 28113038Sobrien#include <sys/cdefs.h> 29113038Sobrien__FBSDID("$FreeBSD: head/sys/boot/ia64/ski/main.c 163897 2006-11-02 01:23:18Z marcel $"); 3083364Sdfr 3183364Sdfr#include <stand.h> 3283364Sdfr#include <string.h> 3383364Sdfr#include <setjmp.h> 3483364Sdfr#include <machine/fpu.h> 3583364Sdfr 3683364Sdfr#include "bootstrap.h" 3783364Sdfr#include "libski.h" 3883364Sdfr 3983364Sdfrextern char bootprog_name[]; 4083364Sdfrextern char bootprog_rev[]; 4183364Sdfrextern char bootprog_date[]; 4283364Sdfrextern char bootprog_maker[]; 4383364Sdfr 4483364Sdfrstruct ski_devdesc currdev; /* our current device */ 4583364Sdfrstruct arch_switch archsw; /* MI/MD interface boundary */ 4683364Sdfr 47135697Smarcelstatic int 48135697Smarcelski_autoload(void) 49135697Smarcel{ 50135697Smarcel 51135697Smarcel return (0); 52135697Smarcel} 53135697Smarcel 5483364Sdfrvoid 55117677Smarcelski_main(void) 5683364Sdfr{ 5783364Sdfr static char malloc[512*1024]; 5883364Sdfr int i; 5983364Sdfr 6083364Sdfr /* 6183364Sdfr * initialise the heap as early as possible. Once this is done, 6283364Sdfr * alloc() is usable. The stack is buried inside us, so this is 6383364Sdfr * safe. 6483364Sdfr */ 6583364Sdfr setheap((void *)malloc, (void *)(malloc + 512*1024)); 6683364Sdfr 6783364Sdfr /* 6883364Sdfr * XXX Chicken-and-egg problem; we want to have console output 6983364Sdfr * early, but some console attributes may depend on reading from 7083364Sdfr * eg. the boot device, which we can't do yet. We can use 7183364Sdfr * printf() etc. once this is done. 7283364Sdfr */ 7383364Sdfr cons_probe(); 7483364Sdfr 7583364Sdfr /* 7683364Sdfr * March through the device switch probing for things. 7783364Sdfr */ 7883364Sdfr for (i = 0; devsw[i] != NULL; i++) 7983364Sdfr if (devsw[i]->dv_init != NULL) 8083364Sdfr (devsw[i]->dv_init)(); 8183364Sdfr 8283364Sdfr printf("\n"); 8383364Sdfr printf("%s, Revision %s\n", bootprog_name, bootprog_rev); 8483364Sdfr printf("(%s, %s)\n", bootprog_maker, bootprog_date); 8583364Sdfr#if 0 8683364Sdfr printf("Memory: %ld k\n", memsize() / 1024); 8783364Sdfr#endif 8883364Sdfr 8983364Sdfr /* XXX presumes that biosdisk is first in devsw */ 9083364Sdfr currdev.d_dev = devsw[0]; 9183364Sdfr currdev.d_type = currdev.d_dev->dv_type; 92163897Smarcel currdev.d_unit = 0; 9383364Sdfr /* XXX should be able to detect this, default to autoprobe */ 9483364Sdfr currdev.d_kind.skidisk.slice = -1; 9583364Sdfr /* default to 'a' */ 9683364Sdfr currdev.d_kind.skidisk.partition = 0; 9783364Sdfr 9883364Sdfr#if 0 9983364Sdfr /* Create arc-specific variables */ 10083364Sdfr bootfile = GetEnvironmentVariable(ARCENV_BOOTFILE); 10183364Sdfr if (bootfile) 10283364Sdfr setenv("bootfile", bootfile, 1); 10383364Sdfr#endif 10483364Sdfr 10583364Sdfr env_setenv("currdev", EV_VOLATILE, ski_fmtdev(&currdev), 10683364Sdfr ski_setcurrdev, env_nounset); 10783364Sdfr env_setenv("loaddev", EV_VOLATILE, ski_fmtdev(&currdev), env_noset, 10883364Sdfr env_nounset); 10983364Sdfr 11083364Sdfr setenv("LINES", "24", 1); /* optional */ 11183364Sdfr 11283364Sdfr archsw.arch_autoload = ski_autoload; 11383364Sdfr archsw.arch_getdev = ski_getdev; 11483364Sdfr archsw.arch_copyin = ski_copyin; 11583364Sdfr archsw.arch_copyout = ski_copyout; 11683364Sdfr archsw.arch_readin = ski_readin; 11783364Sdfr 11883364Sdfr interact(); /* doesn't return */ 11983364Sdfr 12083364Sdfr exit(0); 12183364Sdfr} 12283364Sdfr 12383364SdfrCOMMAND_SET(quit, "quit", "exit the loader", command_quit); 12483364Sdfr 12583364Sdfrstatic int 12683364Sdfrcommand_quit(int argc, char *argv[]) 12783364Sdfr{ 12883364Sdfr exit(0); 12983364Sdfr return (CMD_OK); 13083364Sdfr} 131