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$"); 3083364Sdfr 3183364Sdfr#include <stand.h> 3283364Sdfr#include <string.h> 3383364Sdfr#include <setjmp.h> 3483364Sdfr#include <machine/fpu.h> 3583364Sdfr 36164010Smarcel#include <libia64.h> 3783364Sdfr#include "libski.h" 3883364Sdfr 3983364Sdfrextern char bootprog_name[]; 4083364Sdfrextern char bootprog_rev[]; 4183364Sdfrextern char bootprog_date[]; 4283364Sdfrextern char bootprog_maker[]; 4383364Sdfr 44164010Smarcelstruct devdesc currdev; /* our current device */ 45164010Smarcelstruct arch_switch archsw; /* MI/MD interface boundary */ 4683364Sdfr 4783364Sdfrvoid 48117677Smarcelski_main(void) 4983364Sdfr{ 5083364Sdfr static char malloc[512*1024]; 5183364Sdfr int i; 5283364Sdfr 5383364Sdfr /* 5483364Sdfr * initialise the heap as early as possible. Once this is done, 5583364Sdfr * alloc() is usable. The stack is buried inside us, so this is 5683364Sdfr * safe. 5783364Sdfr */ 5883364Sdfr setheap((void *)malloc, (void *)(malloc + 512*1024)); 5983364Sdfr 6083364Sdfr /* 6183364Sdfr * XXX Chicken-and-egg problem; we want to have console output 6283364Sdfr * early, but some console attributes may depend on reading from 6383364Sdfr * eg. the boot device, which we can't do yet. We can use 6483364Sdfr * printf() etc. once this is done. 6583364Sdfr */ 6683364Sdfr cons_probe(); 6783364Sdfr 6883364Sdfr /* 6983364Sdfr * March through the device switch probing for things. 7083364Sdfr */ 7183364Sdfr for (i = 0; devsw[i] != NULL; i++) 7283364Sdfr if (devsw[i]->dv_init != NULL) 7383364Sdfr (devsw[i]->dv_init)(); 7483364Sdfr 7583364Sdfr printf("\n"); 7683364Sdfr printf("%s, Revision %s\n", bootprog_name, bootprog_rev); 7783364Sdfr printf("(%s, %s)\n", bootprog_maker, bootprog_date); 7883364Sdfr#if 0 7983364Sdfr printf("Memory: %ld k\n", memsize() / 1024); 8083364Sdfr#endif 81164010Smarcel 8283364Sdfr /* XXX presumes that biosdisk is first in devsw */ 8383364Sdfr currdev.d_dev = devsw[0]; 8483364Sdfr currdev.d_type = currdev.d_dev->dv_type; 85163897Smarcel currdev.d_unit = 0; 8683364Sdfr 8783364Sdfr#if 0 8883364Sdfr /* Create arc-specific variables */ 8983364Sdfr bootfile = GetEnvironmentVariable(ARCENV_BOOTFILE); 9083364Sdfr if (bootfile) 9183364Sdfr setenv("bootfile", bootfile, 1); 9283364Sdfr#endif 9383364Sdfr 94164010Smarcel env_setenv("currdev", EV_VOLATILE, ia64_fmtdev(&currdev), 95164010Smarcel ia64_setcurrdev, env_nounset); 96164010Smarcel env_setenv("loaddev", EV_VOLATILE, ia64_fmtdev(&currdev), env_noset, 9783364Sdfr env_nounset); 9883364Sdfr 9983364Sdfr setenv("LINES", "24", 1); /* optional */ 100220313Smarcel 101164010Smarcel archsw.arch_autoload = ia64_autoload; 102164010Smarcel archsw.arch_copyin = ia64_copyin; 103164010Smarcel archsw.arch_copyout = ia64_copyout; 104220313Smarcel archsw.arch_getdev = ia64_getdev; 105220313Smarcel archsw.arch_loadaddr = ia64_loadaddr; 106220313Smarcel archsw.arch_loadseg = ia64_loadseg; 107164010Smarcel archsw.arch_readin = ia64_readin; 10883364Sdfr 10983364Sdfr interact(); /* doesn't return */ 11083364Sdfr 11183364Sdfr exit(0); 11283364Sdfr} 11383364Sdfr 11483364SdfrCOMMAND_SET(quit, "quit", "exit the loader", command_quit); 11583364Sdfr 11683364Sdfrstatic int 11783364Sdfrcommand_quit(int argc, char *argv[]) 11883364Sdfr{ 11983364Sdfr exit(0); 12083364Sdfr return (CMD_OK); 12183364Sdfr} 122