static void bda_init(void) { dprintf(3, "init bda\n"); struct bios_data_area_s *bda = MAKE_FLATPTR(SEG_BDA, 0); memset(bda, 0, sizeof(*bda)); int esize = EBDA_SIZE_START; u16 ebda_seg = EBDA_SEGMENT_START; extern u8 final_varlow_start[]; if (!CONFIG_MALLOC_UPPERMEMORY) ebda_seg = FLATPTR_TO_SEG(ALIGN_DOWN((u32)final_varlow_start, 1024) - EBDA_SIZE_START*1024); SET_BDA(ebda_seg, ebda_seg); SET_BDA(mem_size_kb, ebda_seg / (1024/16)); // Init ebda struct extended_bios_data_area_s *ebda = get_ebda_ptr(); memset(ebda, 0, sizeof(*ebda)); ebda->size = esize; add_e820((u32)ebda, BUILD_LOWRAM_END-(u32)ebda, E820_RESERVED); // Init extra stack StackPos = (void*)(&ExtraStack[BUILD_EXTRA_STACK_SIZE] - zonelow_base); }
void xen_setup(void) { u64 maxram = 0, maxram_over4G = 0; int i; struct xen_seabios_info *info = (void *)INFO_PHYSICAL_ADDRESS; struct e820entry *e820 = (struct e820entry *)info->e820; validate_info(info); dprintf(1, "xen: copy e820...\n"); for (i = 0; i < info->e820_nr; i++) { struct e820entry *e = &e820[i]; if (e->type == E820_ACPI || e->type == E820_RAM) { u64 end = e->start + e->size; if (end > 0x100000000ull) { end -= 0x100000000ull; if (end > maxram_over4G) maxram_over4G = end; } else if (end > maxram) maxram = end; } add_e820(e->start, e->size, e->type); } RamSize = maxram; RamSizeOver4G = maxram_over4G; }
void ramdisk_setup() { if (!CONFIG_COREBOOT_FLASH || !CONFIG_FLASH_FLOPPY) return; // Find image. struct cbfs_file *file = cbfs_findprefix("floppyimg/", NULL); if (!file) return; u32 size = cbfs_datasize(file); dprintf(3, "Found floppy file %s of size %d\n", cbfs_filename(file), size); int ftype = find_floppy_type(size); if (ftype < 0) { dprintf(3, "No floppy type found for ramdisk size\n"); return; } // Allocate ram for image. void *pos = memalign_tmphigh(PAGE_SIZE, size); if (!pos) { dprintf(3, "Not enough memory for ramdisk\n"); return; } add_e820((u32)pos, size, E820_RESERVED); // Copy image into ram. cbfs_copyfile(file, pos, size); // Setup driver. dprintf(1, "Mapping CBFS floppy %s to addr %p\n", cbfs_filename(file), pos); struct drive_s *drive_g = addFloppy((u32)pos, ftype, DTYPE_RAMDISK); if (drive_g) strtcpy(drive_g->model, cbfs_filename(file), ARRAY_SIZE(drive_g->model)); }
static void ram_probe(void) { dprintf(3, "Find memory size\n"); if (CONFIG_COREBOOT) { coreboot_setup(); } else if (usingXen()) { xen_setup(); } else { // On emulators, get memory size from nvram. u32 rs = ((inb_cmos(CMOS_MEM_EXTMEM2_LOW) << 16) | (inb_cmos(CMOS_MEM_EXTMEM2_HIGH) << 24)); if (rs) rs += 16 * 1024 * 1024; else rs = (((inb_cmos(CMOS_MEM_EXTMEM_LOW) << 10) | (inb_cmos(CMOS_MEM_EXTMEM_HIGH) << 18)) + 1 * 1024 * 1024); RamSize = rs; add_e820(0, rs, E820_RAM); // Check for memory over 4Gig u64 high = ((inb_cmos(CMOS_MEM_HIGHMEM_LOW) << 16) | ((u32)inb_cmos(CMOS_MEM_HIGHMEM_MID) << 24) | ((u64)inb_cmos(CMOS_MEM_HIGHMEM_HIGH) << 32)); RamSizeOver4G = high; add_e820(0x100000000ull, high, E820_RAM); /* reserve 256KB BIOS area at the end of 4 GB */ add_e820(0xfffc0000, 256*1024, E820_RESERVED); } // Don't declare any memory between 0xa0000 and 0x100000 add_e820(BUILD_LOWRAM_END, BUILD_BIOS_ADDR-BUILD_LOWRAM_END, E820_HOLE); // Mark known areas as reserved. add_e820(BUILD_BIOS_ADDR, BUILD_BIOS_SIZE, E820_RESERVED); u32 count = qemu_cfg_e820_entries(); if (count) { struct e820_reservation entry; int i; for (i = 0; i < count; i++) { qemu_cfg_e820_load_next(&entry); add_e820(entry.address, entry.length, entry.type); } } else if (kvm_para_available()) { // Backwards compatibility - provide hard coded range. // 4 pages before the bios, 3 pages for vmx tss pages, the // other page for EPT real mode pagetable add_e820(0xfffbc000, 4*4096, E820_RESERVED); } dprintf(1, "Ram Size=0x%08x (0x%016llx high)\n", RamSize, RamSizeOver4G); }
void xen_ramsize_preinit(void) { int i; struct xen_seabios_info *info = (void *)INFO_PHYSICAL_ADDRESS; struct e820entry *e820 = (struct e820entry *)info->e820; validate_info(info); dprintf(1, "xen: copy e820...\n"); for (i = 0; i < info->e820_nr; i++) { struct e820entry *e = &e820[i]; add_e820(e->start, e->size, e->type); } }
void qemu_preinit(void) { qemu_detect(); if (!CONFIG_QEMU) return; if (runningOnXen()) { xen_ramsize_preinit(); return; } if (!runningOnQEMU()) { dprintf(1, "Warning: No QEMU Northbridge found (isapc?)\n"); PlatformRunningOn |= PF_QEMU; kvm_detect(); } // On emulators, get memory size from nvram. u32 rs = ((rtc_read(CMOS_MEM_EXTMEM2_LOW) << 16) | (rtc_read(CMOS_MEM_EXTMEM2_HIGH) << 24)); if (rs) rs += 16 * 1024 * 1024; else rs = (((rtc_read(CMOS_MEM_EXTMEM_LOW) << 10) | (rtc_read(CMOS_MEM_EXTMEM_HIGH) << 18)) + 1 * 1024 * 1024); RamSize = rs; add_e820(0, rs, E820_RAM); /* reserve 256KB BIOS area at the end of 4 GB */ add_e820(0xfffc0000, 256*1024, E820_RESERVED); dprintf(1, "RamSize: 0x%08x [cmos]\n", RamSize); }
static void bda_init(void) { dprintf(3, "init bda\n"); struct bios_data_area_s *bda = MAKE_FLATPTR(SEG_BDA, 0); memset(bda, 0, sizeof(*bda)); #if CONFIG_INT10_SERIAL_CONSOLE // set the default INT10 to serial console value #if CONFIG_CHECK_CMOS_SETTING_FOR_CONSOLE_ENABLE if (!cmos_serial_console_debug_level) SET_BDA(video_mode, UART_OUTPUT_DISABLED); else SET_BDA(video_mode, UART_OUTPUT_ENABLED); #else SET_BDA(video_mode, UART_OUTPUT_ENABLED); #endif #endif int esize = EBDA_SIZE_START; u16 ebda_seg = EBDA_SEGMENT_START; extern u8 final_varlow_start[]; if (!CONFIG_MALLOC_UPPERMEMORY) ebda_seg = FLATPTR_TO_SEG(ALIGN_DOWN((u32)final_varlow_start, 1024) - EBDA_SIZE_START*1024); SET_BDA(ebda_seg, ebda_seg); SET_BDA(mem_size_kb, ebda_seg / (1024/16)); // Init ebda struct extended_bios_data_area_s *ebda = get_ebda_ptr(); memset(ebda, 0, sizeof(*ebda)); ebda->size = esize; add_e820((u32)ebda, BUILD_LOWRAM_END-(u32)ebda, E820_RESERVED); // Init extra stack StackPos = (void*)(&ExtraStack[BUILD_EXTRA_STACK_SIZE] - zonelow_base); }
static void init_bda(void) { dprintf(3, "init bda\n"); struct bios_data_area_s *bda = MAKE_FLATPTR(SEG_BDA, 0); memset(bda, 0, sizeof(*bda)); int esize = EBDA_SIZE_START; SET_BDA(mem_size_kb, BUILD_LOWRAM_END/1024 - esize); u16 ebda_seg = EBDA_SEGMENT_START; SET_BDA(ebda_seg, ebda_seg); // Init ebda struct extended_bios_data_area_s *ebda = get_ebda_ptr(); memset(ebda, 0, sizeof(*ebda)); ebda->size = esize; add_e820((u32)MAKE_FLATPTR(ebda_seg, 0), GET_EBDA(ebda_seg, size) * 1024 , E820_RESERVED); // Init extra stack StackPos = (void*)(&ExtraStack[BUILD_EXTRA_STACK_SIZE] - datalow_base); }