Ejemplo n.º 1
0
void
ski_main(void)
{
	static char malloc[512*1024];
	int i;

	/* 
	 * initialise the heap as early as possible.  Once this is done,
	 * alloc() is usable. The stack is buried inside us, so this is
	 * safe.
	 */
	setheap((void *)malloc, (void *)(malloc + 512*1024));

	/* 
	 * XXX Chicken-and-egg problem; we want to have console output
	 * early, but some console attributes may depend on reading from
	 * eg. the boot device, which we can't do yet.  We can use
	 * printf() etc. once this is done.
	 */
	cons_probe();

	/*
	 * March through the device switch probing for things.
	 */
	for (i = 0; devsw[i] != NULL; i++)
		if (devsw[i]->dv_init != NULL)
			(devsw[i]->dv_init)();

	printf("\n");
	printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
	printf("(%s, %s)\n", bootprog_maker, bootprog_date);
#if 0
	printf("Memory: %ld k\n", memsize() / 1024);
#endif

	/* XXX presumes that biosdisk is first in devsw */
	currdev.d_dev = devsw[0];
	currdev.d_type = currdev.d_dev->dv_type;
	currdev.d_unit = 0;

#if 0
	/* Create arc-specific variables */
	bootfile = GetEnvironmentVariable(ARCENV_BOOTFILE);
	if (bootfile)
		setenv("bootfile", bootfile, 1);
#endif

	env_setenv("currdev", EV_VOLATILE, ia64_fmtdev(&currdev),
	    ia64_setcurrdev, env_nounset);
	env_setenv("loaddev", EV_VOLATILE, ia64_fmtdev(&currdev), env_noset,
	    env_nounset);

	setenv("LINES", "24", 1);	/* optional */

	archsw.arch_autoload = ia64_autoload;
	archsw.arch_copyin = ia64_copyin;
	archsw.arch_copyout = ia64_copyout;
	archsw.arch_getdev = ia64_getdev;
	archsw.arch_loadaddr = ia64_loadaddr;
	archsw.arch_loadseg = ia64_loadseg;
	archsw.arch_readin = ia64_readin;

	interact();			/* doesn't return */

	exit(0);
}
Ejemplo n.º 2
0
EFI_STATUS
main(int argc, CHAR16 *argv[])
{
    struct devdesc currdev;
    EFI_LOADED_IMAGE *img;
    char *dev;
    int i;

    /*
     * XXX Chicken-and-egg problem; we want to have console output
     * early, but some console attributes may depend on reading from
     * eg. the boot device, which we can't do yet.  We can use
     * printf() etc. once this is done.
     */
    cons_probe();

    printf("\n%s, Revision %s\n", bootprog_name, bootprog_rev);

    find_pal_proc();

    /*
     * March through the device switch probing for things.
     */
    for (i = 0; devsw[i] != NULL; i++)
        if (devsw[i]->dv_init != NULL)
            (devsw[i]->dv_init)();

    /*
     * Disable the watchdog timer. By default the boot manager sets
     * the timer to 5 minutes before invoking a boot option. If we
     * want to return to the boot manager, we have to disable the
     * watchdog timer and since we're an interactive program, we don't
     * want to wait until the user types "quit". The timer may have
     * fired by then. We don't care if this fails. It does not prevent
     * normal functioning in any way...
     */
    BS->SetWatchdogTimer(0, 0, 0, NULL);

    /* Get our loaded image protocol interface structure. */
    BS->HandleProtocol(IH, &imgid, (VOID**)&img);

    bzero(&currdev, sizeof(currdev));
    efi_handle_lookup(img->DeviceHandle, &currdev.d_dev, &currdev.d_unit);
    currdev.d_type = currdev.d_dev->dv_type;

    env_setenv("loaddev", EV_VOLATILE, ia64_fmtdev(&currdev), env_noset,
               env_nounset);

    dev = get_dev_option(argc, argv);
    if (dev == NULL)
        dev = ia64_fmtdev(&currdev);

    env_setenv("currdev", EV_VOLATILE, dev, ia64_setcurrdev, env_nounset);

    setenv("LINES", "24", 1);	/* optional */

    archsw.arch_autoload = ia64_autoload;
    archsw.arch_copyin = ia64_copyin;
    archsw.arch_copyout = ia64_copyout;
    archsw.arch_getdev = ia64_getdev;
    archsw.arch_loadaddr = ia64_loadaddr;
    archsw.arch_loadseg = ia64_loadseg;
    archsw.arch_readin = ia64_readin;

    interact();			/* doesn't return */

    return (EFI_SUCCESS);		/* keep compiler happy */
}
Ejemplo n.º 3
0
/*
 * Load the information expected by the kernel.
 *
 * - The kernel environment is copied into kernel space.
 * - Module metadata are formatted and placed in kernel space.
 */
int
bi_load(struct preloaded_file *fp, uint64_t *bi_addr)
{
	struct bootinfo bi;
	struct preloaded_file *xp;
	struct file_metadata *md;
	struct devdesc *rootdev;
	char *rootdevname;
	vm_offset_t addr, ssym, esym;

	bzero(&bi, sizeof(struct bootinfo));
	bi.bi_magic = BOOTINFO_MAGIC;
	bi.bi_version = 1;
	bi.bi_boothowto = bi_getboothowto(fp->f_args);

	/* 
	 * Allow the environment variable 'rootdev' to override the supplied
	 * device. This should perhaps go to MI code and/or have $rootdev
	 * tested/set by MI code before launching the kernel.
	 */
	rootdevname = getenv("rootdev");
	ia64_getdev((void**)&rootdev, rootdevname, NULL);
	if (rootdev != NULL) {
		/* Try reading /etc/fstab to select the root device. */
		getrootmount(ia64_fmtdev(rootdev));
		free(rootdev);
	}

	md = file_findmetadata(fp, MODINFOMD_SSYM);
	ssym = (md != NULL) ? *((vm_offset_t *)&(md->md_data)) : 0;
	md = file_findmetadata(fp, MODINFOMD_ESYM);
	esym = (md != NULL) ? *((vm_offset_t *)&(md->md_data)) : 0;
	if (ssym != 0 && esym != 0) {
		bi.bi_symtab = ssym;
		bi.bi_esymtab = esym;
	}

	/* Find the last module in the chain. */
	addr = 0;
	for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
		if (addr < (xp->f_addr + xp->f_size))
			addr = xp->f_addr + xp->f_size;
	}

	addr = (addr + 15) & ~15;

	/* Copy module list and metadata. */
	bi.bi_modulep = addr;
	addr = bi_copymodules(addr);
	if (addr <= bi.bi_modulep) {
		addr = bi.bi_modulep;
		bi.bi_modulep = 0;
	}

	addr = (addr + 15) & ~15;

	/* Copy our environment. */
	bi.bi_envp = addr;
	addr = bi_copyenv(addr);
	if (addr <= bi.bi_envp) {
		addr = bi.bi_envp;
		bi.bi_envp = 0;
	}

	addr = (addr + PAGE_MASK) & ~PAGE_MASK;
	bi.bi_kernend = addr;

	return (ldr_bootinfo(&bi, bi_addr));
}
Ejemplo n.º 4
0
/*
 * Load the information expected by the kernel.
 *
 * - The kernel environment is copied into kernel space.
 * - Module metadata are formatted and placed in kernel space.
 */
int
ia64_bootinfo(struct preloaded_file *fp, struct bootinfo **res)
{
	struct bootinfo bi;
	struct preloaded_file *xp;
	struct file_metadata *md;
	struct devdesc *rootdev;
	char *rootdevname;
	vm_offset_t addr, ssym, esym;
	int error;

	*res = NULL;
	bzero(&bi, sizeof(struct bootinfo));
	bi.bi_magic = BOOTINFO_MAGIC;
	bi.bi_version = 1;
	bi.bi_boothowto = bi_getboothowto(fp->f_args);

	/* 
	 * Allow the environment variable 'rootdev' to override the supplied
	 * device. This should perhaps go to MI code and/or have $rootdev
	 * tested/set by MI code before launching the kernel.
	 */
	rootdevname = getenv("rootdev");
	ia64_getdev((void**)&rootdev, rootdevname, NULL);
	if (rootdev != NULL) {
		/* Try reading /etc/fstab to select the root device. */
		getrootmount(ia64_fmtdev(rootdev));
		free(rootdev);
	}

	md = file_findmetadata(fp, MODINFOMD_SSYM);
	ssym = (md != NULL) ? *((vm_offset_t *)&(md->md_data)) : 0;
	md = file_findmetadata(fp, MODINFOMD_ESYM);
	esym = (md != NULL) ? *((vm_offset_t *)&(md->md_data)) : 0;
	if (ssym != 0 && esym != 0) {
		bi.bi_symtab = ssym;
		bi.bi_esymtab = esym;
	}

	/* Find the last module in the chain. */
	addr = 0;
	for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
		if (addr < (xp->f_addr + xp->f_size))
			addr = xp->f_addr + xp->f_size;
	}

	addr = (addr + 15) & ~15;

	/* Copy module list and metadata. */
	bi.bi_modulep = addr;
	addr = bi_copymodules(addr);
	if (addr <= bi.bi_modulep) {
		addr = bi.bi_modulep;
		bi.bi_modulep = 0;
	}

	addr = (addr + 15) & ~15;

	/* Copy our environment. */
	bi.bi_envp = addr;
	addr = bi_copyenv(addr);
	if (addr <= bi.bi_envp) {
		addr = bi.bi_envp;
		bi.bi_envp = 0;
	}

	addr = (addr + 15) & ~15;
	bi.bi_kernend = addr;

	error = ia64_platform_bootinfo(&bi, res);
	if (error)
		return (error);

	if (IS_LEGACY_KERNEL()) {
		if (*res == NULL)
			return (EDOOFUS);

		bcopy(&bi, *res, sizeof(bi));
		return (0);
	}

	bi.bi_pbvm_pgtbl = (uintptr_t)ia64_pgtbl;
	bi.bi_pbvm_pgtblsz = ia64_pgtblsz;
	ia64_copyin((void *)bi.bi_memmap, addr, bi.bi_memmap_size);
	bi.bi_memmap = addr;
	addr = (addr + bi.bi_memmap_size + 15) & ~15;
	bi.bi_kernend = addr + sizeof(bi);	
	ia64_copyin(&bi, addr, sizeof(bi));
	*res = (void *)addr;
	return (0);
}