int main(void) { char *memend; int i; WDEBUG_INIT(); WDEBUG('X'); /* Pick up arguments */ kargs = (void *)__args; initial_howto = kargs->howto; initial_bootdev = kargs->bootdev; initial_bootinfo = kargs->bootinfo ? (struct bootinfo *)PTOV(kargs->bootinfo) : NULL; #ifdef COMCONSOLE_DEBUG printf("args at %p initial_howto = %08x bootdev = %08x bootinfo = %p\n", kargs, initial_howto, initial_bootdev, initial_bootinfo); #endif /* Initialize the v86 register set to a known-good state. */ bzero(&v86, sizeof(v86)); v86.efl = PSL_RESERVED_DEFAULT | PSL_I; /* * Initialize the heap as early as possible. Once this is done, * malloc() is usable. * * Don't include our stack in the heap. If the stack is in low * user memory use {end,bios_basemem}. If the stack is in high * user memory but not extended memory then don't let the heap * overlap the stack. If the stack is in extended memory limit * the heap to bios_basemem. * * Be sure to use the virtual bios_basemem address rather then * the physical bios_basemem address or we may overwrite BIOS * data. */ bios_getmem(); memend = (char *)&memend - 0x8000; /* space for stack (16K) */ memend = (char *)((uintptr_t)memend & ~(uintptr_t)(0x1000 - 1)); /* * For day to day usage simple memend setup is more than engouh, * but bigger heap is a must for loading bzipp'ed kernel/modules * "bzf_read: BZ2_bzDecompress returned -3" */ #if defined(LOADER_BZIP2_SUPPORT) if (high_heap_size > 0) { heap_top = PTOV(high_heap_base + high_heap_size); heap_bottom = PTOV(high_heap_base); if (high_heap_base < memtop_copyin) memtop_copyin = high_heap_base; } else #endif if (memend < (char *)_end) { heap_top = PTOV(bios_basemem); heap_bottom = (void *)_end; } else { if (memend > (char *)PTOV(bios_basemem)) memend = (char *)PTOV(bios_basemem); heap_top = memend; heap_bottom = (void *)_end; } setheap(heap_bottom, heap_top); /* * 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. The previous boot stage * might have requested a video or serial preference, in which case we * set it. */ bi_setboothowto(initial_howto); if (initial_howto & RB_MUTE) { setenv("console", "nullconsole", 1); } else if ((initial_howto & (RB_VIDEO|RB_SERIAL)) == (RB_VIDEO|RB_SERIAL)) { setenv("console", "vidconsole comconsole", 1); } else if (initial_howto & RB_VIDEO) { setenv("console", "vidconsole", 1); } else if (initial_howto & RB_SERIAL) { setenv("console", "comconsole", 1); } else { /* XXX leave to cons_probe() */ } cons_probe(); /* * Initialise the block cache */ bcache_init(32, 512); /* 16k cache XXX tune this */ /* * Special handling for PXE and CD booting. */ if (kargs->bootinfo == 0) { /* * We only want the PXE disk to try to init itself in the below * walk through devsw if we actually booted off of PXE. */ if (kargs->bootflags & KARGS_FLAGS_PXE) pxe_enable(kargs->pxeinfo ? PTOV(kargs->pxeinfo) : NULL); else if (kargs->bootflags & KARGS_FLAGS_CD) bc_add(initial_bootdev); } archsw.arch_autoload = i386_autoload; archsw.arch_getdev = i386_getdev; archsw.arch_copyin = i386_copyin; archsw.arch_copyout = i386_copyout; archsw.arch_readin = i386_readin; archsw.arch_isainb = isa_inb; archsw.arch_isaoutb = isa_outb; /* * March through the device switch probing for things. */ for (i = 0; devsw[i] != NULL; i++) { WDEBUG('M' + i); if (devsw[i]->dv_init != NULL) (devsw[i]->dv_init)(); WDEBUG('M' + i); } printf("BIOS %dkB/%dkB available memory\n", bios_basemem / 1024, bios_extmem / 1024); if (initial_bootinfo != NULL) { initial_bootinfo->bi_basemem = bios_basemem / 1024; initial_bootinfo->bi_extmem = bios_extmem / 1024; } /* detect ACPI for future reference */ biosacpi_detect(); /* detect SMBIOS for future reference */ smbios_detect(NULL); /* detect PCI BIOS for future reference */ biospci_detect(); /* enable EHCI */ setenv("ehci_load", "YES", 1); /* enable XHCI */ setenv("xhci_load", "YES", 1); printf("\n"); printf("%s, Revision %s\n", bootprog_name, bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); extract_currdev(); /* set $currdev and $loaddev */ setenv("LINES", "24", 1); /* optional */ bios_getsmap(); interact(); /* doesn't return */ /* if we ever get here, it is an error */ return (1); }
int main(void) { int i; /* Set machine type to PC98_SYSTEM_PARAMETER. */ set_machine_type(); /* Pick up arguments */ kargs = (void *)__args; initial_howto = kargs->howto; initial_bootdev = kargs->bootdev; initial_bootinfo = kargs->bootinfo ? (struct bootinfo *)PTOV(kargs->bootinfo) : NULL; /* Initialize the v86 register set to a known-good state. */ bzero(&v86, sizeof(v86)); v86.efl = PSL_RESERVED_DEFAULT | PSL_I; /* * Initialise the heap as early as possible. Once this is done, malloc() is usable. */ bios_getmem(); #if defined(LOADER_BZIP2_SUPPORT) if (high_heap_size > 0) { heap_top = PTOV(high_heap_base + high_heap_size); heap_bottom = PTOV(high_heap_base); if (high_heap_base < memtop_copyin) memtop_copyin = high_heap_base; } else #endif { heap_top = (void *)PTOV(bios_basemem); heap_bottom = (void *)end; } setheap(heap_bottom, heap_top); /* * 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. * If the previous boot stage has requested a serial console, prefer that. */ bi_setboothowto(initial_howto); if (initial_howto & RB_MULTIPLE) { if (initial_howto & RB_SERIAL) setenv("console", "comconsole vidconsole", 1); else setenv("console", "vidconsole comconsole", 1); } else if (initial_howto & RB_SERIAL) setenv("console", "comconsole", 1); else if (initial_howto & RB_MUTE) setenv("console", "nullconsole", 1); cons_probe(); /* * Initialise the block cache */ bcache_init(32, 512); /* 16k cache XXX tune this */ /* * Special handling for PXE and CD booting. */ if (kargs->bootinfo == 0) { /* * We only want the PXE disk to try to init itself in the below * walk through devsw if we actually booted off of PXE. */ if (kargs->bootflags & KARGS_FLAGS_PXE) pxe_enable(kargs->pxeinfo ? PTOV(kargs->pxeinfo) : NULL); else if (kargs->bootflags & KARGS_FLAGS_CD) bc_add(initial_bootdev); } archsw.arch_autoload = i386_autoload; archsw.arch_getdev = i386_getdev; archsw.arch_copyin = i386_copyin; archsw.arch_copyout = i386_copyout; archsw.arch_readin = i386_readin; archsw.arch_isainb = isa_inb; archsw.arch_isaoutb = isa_outb; archsw.arch_loadaddr = pc98_loadaddr; /* * 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("BIOS %dkB/%dkB available memory\n", bios_basemem / 1024, bios_extmem / 1024); if (initial_bootinfo != NULL) { initial_bootinfo->bi_basemem = bios_basemem / 1024; initial_bootinfo->bi_extmem = bios_extmem / 1024; } printf("\n"); printf("%s, Revision %s\n", bootprog_name, bootprog_rev); printf("(%s, %s)\n", bootprog_maker, bootprog_date); extract_currdev(); /* set $currdev and $loaddev */ setenv("LINES", "24", 1); /* optional */ interact(); /* doesn't return */ /* if we ever get here, it is an error */ return (1); }