void __start(struct bios_service_table *pbios_services) { bios_services = pbios_services; __asm("xchg %bx, %bx"); bios_console_init(&bios_console); stdout->handle.pointer = &bios_console.dev; /* Initialize the memory map, find all the tables. */ mmap_init(); tables_init(); vbe_init(); /*gd_memory_map_entry mmap[100]; size_t nentries = 100, key = 0; mmap_get(&mmap, nentries, &nentries, &key); for (size_t i = 0; i < nentries; i++) { printf("Entry %d: %llx -> %llx, %d\n", i, mmap[i].physical_start, mmap[i].physical_start + mmap[i].size, mmap[i].type); }*/ //extern gd_rsdt_pointer_table rsdt_pointer; //extern gd_pc_pointer_table pc_pointer; //if (rsdt_pointer.header.length) { // printf("RSDT: %x\nXSDT: %llx\n", rsdt_pointer.rsdt_address, rsdt_pointer.xsdt_address); //} //if (pc_pointer.header.length) { // printf("MPS: %c%c%c%c\nSMBIOS: %x\n", pc_pointer.mpfp.signature[0], // pc_pointer.mpfp.signature[1], // pc_pointer.mpfp.signature[2], // pc_pointer.mpfp.signature[3], pc_pointer.smbios_entry_point_address); //} for(;;); }
static adv_error vbe_init2(int device_id, adv_output output, unsigned overlay_size, adv_cursor cursor) { const adv_device* i; (void)cursor; if (sizeof(vbe_video_mode) > MODE_DRIVER_MODE_SIZE_MAX) return -1; if (os_internal_brokenint10_active()) { error_set("Detected broken video BIOS.\n"); return -1; } if (output != adv_output_auto && output != adv_output_fullscreen) { error_set("Only fullscreen output is supported.\n"); return -1; } i = DEVICE; while (i->name && i->id != device_id) ++i; if (!i->name) return -1; if (vbe_init() != 0) return -1; vbe_state2.flags = VIDEO_DRIVER_FLAGS_MODE_PALETTE8 | VIDEO_DRIVER_FLAGS_MODE_BGR15 | VIDEO_DRIVER_FLAGS_MODE_BGR16 | VIDEO_DRIVER_FLAGS_MODE_BGR24 | VIDEO_DRIVER_FLAGS_MODE_BGR32 | VIDEO_DRIVER_FLAGS_OUTPUT_FULLSCREEN; vbe_probe(); return 0; }
/** Main function of the PC loader. */ void platform_init(void) { /* Set up console output. */ console_init(); /* Initialize the architecture. */ arch_init(); /* Initialize hardware. */ memory_init(); disk_init(); vbe_init(); /* Parse information from Multiboot. */ multiboot_init(); /* Call the main function. */ loader_main(); }
void printusage( void ) { printf("\nBOOM 2 Engine by Ivaylo Beltchev\n"); printf("MS-DOS version\n"); printf("Usage: boomdos <boo file> [/x<width> /y<height> /w /b]\n"); printf("/x<width>, /y<height> - screen size (requires VBE 2.0)\n"); printf("/w - don't wait for the vertical retrace (VBE 2.0 only)\n"); printf("/b - back buffer is in video memory (VBE 2.0 only)\n"); printf("Example: boomdos level.boo /x640 /y480 /w\n"); printf("Controls:\n"); printf("Arrows - forward, backward, turn left, turn right\n"); printf("Home/PgUp - strafe left/right\n"); printf("X - crouch\n"); printf("Space - jump\n"); printf("A/Z - look up/down\n"); printf("O/P - rotate left/right\n"); printf("NumPad 5 - center view\n"); printf("Shift - run\n"); printf("Esc - exit\n\n"); if (!vbe_init()) { printf("VBE 2.0 not found.\n\n"); vbe_done(); return; } printf("Press Enter to view the available video modes. Esc to skip.\n"); char c; do c=getch(); while (c!=27 && c!=13); if (c==27) { vbe_done(); return; } for (int i=0;i<vbemodenum;i++) if (vbemodes[i].bpp==8) printf("%dx%d\n",vbemodes[i].width,vbemodes[i].height); vbe_done(); }
// application entry point void main(int argc,char *argv[]) { int system_time=0; int frame_counter=0; int time0; char s[20]=""; if (argc<2) { printusage(); return; } // parses command line parameters parsecmdline(argc-2,argv+2); // initializes the video mode and geometry module int mode=-1; if (vbe_init()) { mode=vbe_findmode(scrwidth,scrheight,8); if (!mode) mode=-1; } if (mode==-1) vbe_done(); if (!vbe_setmode(mode,backbuffl)) goto err; setscreensize(vbe_width,vbe_height); scr_cols=vbe_width; scr_bpp=vbe_bpp; // initializes the keyboard kbd_init(); // initializes the timer timer_init(); // initializes the mouse mouse_init(); // reads the map if (!map_init(argv[1])) goto err; vbe_setpal((Tcolor *)palette,0,256); // main loop time0=timer_clocks; while(player_idle(timer_clocks)) { // draws the current frame draw_init(vbe_backbuffer,vbe_width,vbe_height); map_draw(); // calculates the frame rate frame_counter++; int dt=timer_clocks-time0; if (dt>500) { float fps = (frame_counter*1000.)/dt; sprintf(s,"%.1f FPS",fps); time0 = timer_clocks; frame_counter = 0; } textout(vbe_backbuffer,0,0,s,255); // flips the video pages vbe_flip(waitfl); // applies the mouse movement if (player_keys & kRUN) player_rotate(-mousedy*0.01,0,-mousedx*0.01); else player_rotate(-mousedy*0.005,0,-mousedx*0.005); mousedx=0;mousedy=0; // clears the keyboard queue while (kbhit()) getch(); } err: vbe_done(); vbe_settext(); }
int main(int argc, char *argv[]) { void *tarfile_addr; size_t tarfile_length; void *elf_file_addr; size_t elf_file_length; void *free_space; uint32_t cr3; char *pfree; kprintf("Loading the Anvil...\n"); parse_cmd_line(argc, argv); cpu_init(); /* * Get all the Grub info now so we can touch memory and it won't matter * too much if we trash it. */ mbi_mem_get_info(); free_space = mbi_module_get_info(&tarfile_addr, &tarfile_length); // free_space = 0x80100000; // tarfile_addr = (uintptr_t)0x80012000; // tarfile_length = 3150336; sysinfo.initrd_info.base_addr = (uintptr_t)tarfile_addr; sysinfo.initrd_info.length = tarfile_length; get_sysinfo(); /* Load the OS. We'll be loading 2 files, the kernel and init */ pfree = free_space; kprintf("\nLoading kernel\n========================\n"); /* Assume the module is a TAR file and search it for the files */ if (tar_search(tarfile_addr, tarfile_length, "anvil-knl", &elf_file_addr, &elf_file_length) == -1) { kprintf("Couldn't untar kernel\n"); return 0; } /* Now load the kernel. It should be a single segment */ if (elf_load(pfree, elf_file_addr, &sysinfo.kernel_program_info) == -1) { return 0; } sysinfo.kernel_program_info.seginfo[0].paddr = (uintptr_t)pfree; /* Skip over the kernel (and an 8 page stack */ pfree += sysinfo.kernel_program_info.seginfo[0].length + 8 * __PAGESIZE; kprintf("\nLoading init\n========================\n"); /* Assume the module is a TAR file and search it for the pieces */ if (tar_search(tarfile_addr, tarfile_length, "init", &elf_file_addr, &elf_file_length) == 0) { /* Load init */ if (elf_load(pfree, elf_file_addr, &sysinfo.init_program_info) == -1) { return 0; } } else { kprintf("init not found, ignoring\n"); } sysinfo.init_program_info.seginfo[0].paddr = (uintptr_t)pfree; sysinfo.init_program_info.seginfo[1].paddr = (uintptr_t)pfree + sysinfo.init_program_info.seginfo[0].length; vbe_init(); cr3 = paging_init(free_space, sysinfo.kernel_program_info.seginfo[0].length); cpu_switch_longmode(cr3); /* * The return value tells the code in boot.S what to do * * 0: just hang * 1: launch 32bit kernel * 2: launch 64bit kernel * * any other value just hang */ return 2; }
/* * Called from the initial entry point boot_start in biosboot.S * * biosdev: BIOS drive number the system booted from * biossector: Sector number of the NetBSD partition */ void boot2(int biosdev, uint64_t biossector) { extern char twiddle_toggle; int currname; char c; twiddle_toggle = 1; /* no twiddling until we're ready */ initio(boot_params.bp_consdev); #ifdef SUPPORT_PS2 biosmca(); #endif gateA20(); boot_modules_enabled = !(boot_params.bp_flags & X86_BP_FLAGS_NOMODULES); if (boot_params.bp_flags & X86_BP_FLAGS_RESET_VIDEO) biosvideomode(); vbe_init(); /* need to remember these */ boot_biosdev = biosdev; boot_biossector = biossector; /* try to set default device to what BIOS tells us */ bios2dev(biosdev, biossector, &default_devname, &default_unit, &default_partition); /* if the user types "boot" without filename */ default_filename = DEFFILENAME; #ifndef SMALL if (!(boot_params.bp_flags & X86_BP_FLAGS_NOBOOTCONF)) { parsebootconf(BOOTCONF); } else { bootconf.timeout = boot_params.bp_timeout; } /* * If console set in boot.cfg, switch to it. * This will print the banner, so we don't need to explicitly do it */ if (bootconf.consdev) command_consdev(bootconf.consdev); else print_banner(); /* Display the menu, if applicable */ twiddle_toggle = 0; if (bootconf.nummenu > 0) { /* Does not return */ doboottypemenu(); } #else twiddle_toggle = 0; print_banner(); #endif printf("Press return to boot now, any other key for boot menu\n"); for (currname = 0; currname < NUMNAMES; currname++) { printf("booting %s - starting in ", sprint_bootsel(names[currname][0])); #ifdef SMALL c = awaitkey(boot_params.bp_timeout, 1); #else c = awaitkey((bootconf.timeout < 0) ? 0 : bootconf.timeout, 1); #endif if ((c != '\r') && (c != '\n') && (c != '\0')) { if ((boot_params.bp_flags & X86_BP_FLAGS_PASSWORD) == 0) { /* do NOT ask for password */ bootmenu(); /* does not return */ } else { /* DO ask for password */ if (check_password((char *)boot_params.bp_password)) { /* password ok */ printf("type \"?\" or \"help\" for help.\n"); bootmenu(); /* does not return */ } else { /* bad password */ printf("Wrong password.\n"); currname = 0; continue; } } } /* * try pairs of names[] entries, foo and foo.gz */ /* don't print "booting..." again */ bootit(names[currname][0], 0, 0); /* since it failed, try compressed bootfile. */ bootit(names[currname][1], 0, 1); } bootmenu(); /* does not return */ }
int main(int argc, char* argv[]) { char config[128]; int arg_load; unsigned i; printf(OEM_PRODUCT_STR " by " OEM_VENDOR_STR " v" OEM_VERSION_STR "\n"); strcpy(config, "vbe.rc"); arg_load = 0; for(i=1;i<argc;++i) { const char* tok = argv[i]; if (optionmatch(tok, "l")) { arg_load = 1; } else if (optionmatch(tok, "c")) { tok = argv[++i]; if (!tok) { printf("Missing config file path\n"); exit(EXIT_FAILURE); } strcpy(config, tok); } else { printf("Unknown option %s\n", tok); exit(EXIT_FAILURE); } } if (!arg_load) { printf( "Usage:\n" " vbe32 [/l] [/c CONFIG]\n" "Commands:\n" " /l Load the TSR\n" "Options:\n" " /c CONFIG Use this config file instead of vbe.rc\n" ); return EXIT_SUCCESS; } if (detect() != 0) { exit(EXIT_FAILURE); } if (vbe_init(config) != 0) { exit(EXIT_FAILURE); } #if 1 if (install() != 0) { exit(EXIT_FAILURE); } __djgpp_exception_toggle(); keep(0, 0); #else { _go32_dpmi_registers r; r.x.ax = 0x4F02; r.x.bx = 0x4103; vbe_service(&r); } printf("Exit\n"); #endif return EXIT_SUCCESS; }