#include "pci_regs.h" // PCI_INTERRUPT_LINE
#include "ioport.h" // inl
#include "config.h" // CONFIG_*
+#include "paravirt.h" // RamSize
#include "dev-q35.h"
/****************************************************/
if (!cbm)
goto fail;
- u64 maxram = 0, maxram_over4G = 0;
int i, count = MEM_RANGE_COUNT(cbm);
for (i=0; i<count; i++) {
struct cb_memory_range *m = &cbm->map[i];
u32 type = m->type;
- if (type == CB_MEM_TABLE) {
+ if (type == CB_MEM_TABLE)
type = E820_RESERVED;
- } else if (type == E820_ACPI || type == E820_RAM) {
- u64 end = m->start + m->size;
- if (end > 0x100000000ull) {
- end -= 0x100000000ull;
- if (end > maxram_over4G)
- maxram_over4G = end;
- } else if (end > maxram)
- maxram = end;
- }
add_e820(m->start, m->size, type);
}
- RamSize = maxram;
- RamSizeOver4G = maxram_over4G;
-
// Ughh - coreboot likes to set a map at 0x0000-0x1000, but this
// confuses grub. So, override it.
add_e820(0, 16*1024, E820_RAM);
fail:
// No table found.. Use 16Megs as a dummy value.
dprintf(1, "Unable to find coreboot table!\n");
- RamSize = 16*1024*1024;
- RamSizeOver4G = 0;
add_e820(0, 16*1024*1024, E820_RAM);
return;
}
#include "util.h" // debug_enter
#include "pic.h" // enable_hwirq
-// Amount of continuous ram under 4Gig
-u32 RamSize VARFSEG;
-// Amount of continuous ram >4Gig
-u64 RamSizeOver4G;
-
/****************************************************************
* Misc 16bit ISRs
#include "util.h" // dprintf
#include "config.h" // CONFIG_*
#include "pci.h" // pcimem_start
+#include "paravirt.h" // RamSize
#define MSR_MTRRcap 0x000000fe
#define MSR_MTRRfix64K_00000 0x00000250
#include "pci.h" // create_pirtable
#include "xen.h" // xen_biostable_setup
+// Amount of continuous ram under 4Gig
+u32 RamSize;
+// Amount of continuous ram >4Gig
+u64 RamSizeOver4G;
// Type of emulator platform.
int PlatformRunningOn VARFSEG;
/* reserve 256KB BIOS area at the end of 4 GB */
add_e820(0xfffc0000, 256*1024, E820_RESERVED);
+
+ dprintf(1, "Ram Size=0x%08x (0x%016llx high)\n", RamSize, RamSizeOver4G);
}
void
#define PF_XEN (1<<1)
#define PF_KVM (1<<2)
+extern u32 RamSize;
+extern u64 RamSizeOver4G;
extern int PlatformRunningOn;
static inline int runningOnQEMU(void) {
#include "ioport.h" // PORT_ATA1_CMD_BASE
#include "config.h" // CONFIG_*
#include "memmap.h" // add_e820
+#include "paravirt.h" // RamSize
#include "dev-q35.h"
/* PM Timer ticks per second (HZ) */
ASSERT32FLAT();
dprintf(3, "malloc preinit\n");
- dprintf(1, "Ram Size=0x%08x (0x%016llx high)\n", RamSize, RamSizeOver4G);
-
// Don't declare any memory between 0xa0000 and 0x100000
add_e820(BUILD_LOWRAM_END, BUILD_BIOS_ADDR-BUILD_LOWRAM_END, E820_HOLE);
addSpace(&ZoneTmpLow, (void *)low_pmm, (void *)low_pmm + low_pmm_size);
}
+u32 LegacyRamSize VARFSEG;
+
+// Calculate the maximum ramsize (less than 4gig) from e820 map.
+static void
+calcRamSize(void)
+{
+ u32 rs = 0;
+ int i;
+ for (i=e820_count-1; i>=0; i--) {
+ struct e820entry *en = &e820_list[i];
+ u64 end = en->start + en->size;
+ u32 type = en->type;
+ if (end <= 0xffffffff && (type == E820_ACPI || type == E820_RAM)) {
+ rs = end;
+ break;
+ }
+ }
+ LegacyRamSize = rs >= 1024*1024 ? rs : 1024*1024;
+}
+
// Update pointers after code relocation.
void
malloc_init(void)
memset((void*)BUILD_BIOS_ADDR, 0, (u32)code32init_end - BUILD_BIOS_ADDR);
addSpace(&ZoneFSeg, (void*)BUILD_BIOS_ADDR, code32init_end);
}
+
+ calcRamSize();
}
void
add_e820((u32)info->dataend, giveback, E820_RAM);
dprintf(1, "Returned %d bytes of ZoneHigh\n", giveback);
}
+
+ calcRamSize();
}
#include "util.h" // dprintf
#include "config.h" // CONFIG_*
+#include "paravirt.h" // RamSize
#include "smbios.h" // struct smbios_entry_point
struct smbios_entry_point *SMBiosAddr;
static void
handle_1588(struct bregs *regs)
{
- u32 rs = GET_GLOBAL(RamSize);
+ u32 rs = GET_GLOBAL(LegacyRamSize);
// According to Ralf Brown's interrupt the limit should be 15M,
// but real machines mostly return max. 63M.
// regs.u.r16.ax = 0;
// regs.u.r16.bx = 0;
- u32 rs = GET_GLOBAL(RamSize);
+ u32 rs = GET_GLOBAL(LegacyRamSize);
// Get the amount of extended memory (above 1M)
if (rs > 16*1024*1024) {
void csm_malloc_preinit(u32 low_pmm, u32 low_pmm_size, u32 hi_pmm,
u32 hi_pmm_size);
void malloc_preinit(void);
+extern u32 LegacyRamSize;
void malloc_init(void);
void malloc_prepboot(void);
void *pmm_malloc(struct zone_s *zone, u32 handle, u32 size, u32 align);
// misc.c
void mathcp_setup(void);
-extern u32 RamSize;
-extern u64 RamSizeOver4G;
extern u8 BiosChecksum;
// version (auto generated file out/version.c)
void xen_ramsize_preinit(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;
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;
}