aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-09-06 15:44:17 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2016-09-06 16:19:54 +0200
commitf4569f4b687e4302e96764aba2c756513b79e2e0 (patch)
tree50282a20130d060f4a8c688e807a84eab97de11b
parent5ea29a8e87a24ac9e2b1ab4f05094102af6a3c9d (diff)
downloadqboot-f4569f4b687e4302e96764aba2c756513b79e2e0.zip
qboot-f4569f4b687e4302e96764aba2c756513b79e2e0.tar.gz
qboot-f4569f4b687e4302e96764aba2c756513b79e2e0.tar.bz2
copy only ~11K down to low memory
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--flat.lds2
-rw-r--r--hwsetup.c7
-rw-r--r--include/bios.h5
-rw-r--r--malloc.c4
4 files changed, 12 insertions, 6 deletions
diff --git a/flat.lds b/flat.lds
index be84ec3..933ed60 100644
--- a/flat.lds
+++ b/flat.lds
@@ -14,12 +14,14 @@ SECTIONS
. = ALIGN(16);
edata = .;
. = 1024K - 128;
+ sinit = .;
.init : {
*(.init);
. = 128 - 16;
*(.resetvector);
. = 128;
}
+ einit = .;
}
ENTRY(main)
diff --git a/hwsetup.c b/hwsetup.c
index 6c7b019..2924383 100644
--- a/hwsetup.c
+++ b/hwsetup.c
@@ -85,8 +85,8 @@ static void setup_pic(void)
void setup_hw(void)
{
const int bdf = 0;
- const uint8_t *bios_start = (uint8_t *)0xffff0000;
- uint8_t *low_start = (uint8_t *)0xf0000;
+ const uint8_t *bios_start = &stext + 0xfff00000;
+ const uint8_t *init_start = &sinit + 0xfff00000;
int pambase;
uint32_t id = pci_config_readl(bdf, 0);
@@ -111,7 +111,8 @@ void setup_hw(void)
// Make ram from 0xf0000-0x100000 read-write and shadow BIOS
// We're still running from 0xffff0000
pci_config_writeb(bdf, pambase, 0x30);
- memcpy(low_start, bios_start, 0x10000);
+ memcpy(&stext, bios_start, &edata - &stext);
+ memcpy(&sinit, init_start, &einit - &sinit);
setup_pic();
}
diff --git a/include/bios.h b/include/bios.h
index eddca6b..bc96f87 100644
--- a/include/bios.h
+++ b/include/bios.h
@@ -47,6 +47,11 @@ extern bool boot_from_cbfs(void *base, size_t sz);
extern uint16_t e820_seg;
extern uint32_t lowmem;
+extern uint8_t stext;
+extern uint8_t edata;
+extern uint8_t sinit;
+extern uint8_t einit;
+
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
static inline void __attribute__((noreturn)) panic(void)
diff --git a/malloc.c b/malloc.c
index 3ab95ed..c8d865b 100644
--- a/malloc.c
+++ b/malloc.c
@@ -1,10 +1,8 @@
#include <inttypes.h>
#include "string.h"
+#include "bios.h"
-extern uint8_t edata;
static uint8_t *fseg_base = &edata;
-
-extern uint8_t stext;
static uint8_t *malloc_top = &stext;
void *malloc(int n)