Пример #1
0
/*
 * Load the information expected by an alpha kernel.
 *
 * - The kernel environment is copied into kernel space.
 * - Module metadata are formatted and placed in kernel space.
 */
int
bi_load(struct bootinfo *bi, struct preloaded_file *fp, char *args)
{
    char			*rootdevname;
    struct ski_devdesc		*rootdev;
    struct preloaded_file	*xp;
    vm_offset_t			addr, bootinfo_addr;
    u_int			pad;
    char			*kernelname;
    vm_offset_t			ssym, esym;
    struct file_metadata	*md;
    EFI_MEMORY_DESCRIPTOR	*memp;

    /*
     * Version 1 bootinfo.
     */
    bi->bi_magic = BOOTINFO_MAGIC;
    bi->bi_version = 1;

    /*
     * Calculate boothowto.
     */
    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");
    ski_getdev((void **)(&rootdev), rootdevname, NULL);
    if (rootdev == NULL) {		/* bad $rootdev/$currdev */
	printf("can't determine root device\n");
	return(EINVAL);
    }

    /* Try reading the /etc/fstab file to select the root device */
    getrootmount(ski_fmtdev((void *)rootdev));
    free(rootdev);

    ssym = esym = 0;
    if ((md = file_findmetadata(fp, MODINFOMD_SSYM)) != NULL)
	ssym = *((vm_offset_t *)&(md->md_data));
    if ((md = file_findmetadata(fp, MODINFOMD_ESYM)) != NULL)
	esym = *((vm_offset_t *)&(md->md_data));
    if (ssym == 0 || esym == 0)
	ssym = esym = 0;		/* sanity */

    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;
    }
    /* pad to a page boundary */
    pad = (u_int)addr & PAGE_MASK;
    if (pad != 0) {
	pad = PAGE_SIZE - pad;
	addr += pad;
    }

    /* copy our environment */
    bi->bi_envp = addr;
    addr = bi_copyenv(addr);

    /* pad to a page boundary */
    pad = (u_int)addr & PAGE_MASK;
    if (pad != 0) {
	pad = PAGE_SIZE - pad;
	addr += pad;
    }
    /* copy module list and metadata */
    bi->bi_modulep = addr;
    addr = bi_copymodules(addr);

    /* all done copying stuff in, save end of loaded object space */
    bi->bi_kernend = addr;

    /* Describe the SKI memory map. */
    bi->bi_memmap = (u_int64_t)(bi + 1);
    bi->bi_memmap_size = 2 * sizeof(EFI_MEMORY_DESCRIPTOR);
    bi->bi_memdesc_size = sizeof(EFI_MEMORY_DESCRIPTOR);
    bi->bi_memdesc_version = 1;

    memp = (EFI_MEMORY_DESCRIPTOR *) bi->bi_memmap;

    memp[0].Type = EfiConventionalMemory;
    memp[0].PhysicalStart = 2L*1024*1024;
    memp[0].VirtualStart = 0;
    memp[0].NumberOfPages = (64L*1024*1024)>>12;
    memp[0].Attribute = EFI_MEMORY_WB;

    memp[1].Type = EfiMemoryMappedIOPortSpace;
    memp[1].PhysicalStart = 0xffffc000000;
    memp[1].VirtualStart = 0;
    memp[1].NumberOfPages = (64L*1024*1024)>>12;
    memp[1].Attribute = EFI_MEMORY_UC;

    return(0);
}
Пример #2
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();

	/*
	 * Initialise the block cache XXX: Fixme: do we need the bcache ?
	 */
	/*	bcache_init(32, 512);	*/	/* 16k XXX tune this */

	/* Initialise skifs.c */

	skifs_dev_init();

	printf("\n");
	printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
#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 = DEVT_DISK;
	currdev.d_kind.skidisk.unit = 0;
	/* XXX should be able to detect this, default to autoprobe */
	currdev.d_kind.skidisk.slice = -1;
	/* default to 'a' */
	currdev.d_kind.skidisk.partition = 0;

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

	env_setenv("currdev", EV_VOLATILE, ski_fmtdev(&currdev),
	    (ev_sethook_t *) ski_setcurrdev, env_nounset);
	env_setenv("loaddev", EV_VOLATILE, ski_fmtdev(&currdev), env_noset,
	    env_nounset);

	setenv("LINES", "24", 1);	/* optional */
    
	archsw.arch_autoload = ski_autoload;
	archsw.arch_getdev = ski_getdev;
	archsw.arch_copyin = ski_copyin;
	archsw.arch_copyout = ski_copyout;
	archsw.arch_readin = ski_readin;

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

	exit(0);
}