aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-05-20 17:15:57 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2015-05-21 11:44:57 +0200
commit3d3a334ec62c68c07ef45f144c77b8ac5c2835bf (patch)
tree901afb9cac9e0b0ff91b3c66258d93f58f2e7672
parenteaae11e17f022188755c67e4dd3436875e84110d (diff)
downloadqboot-3d3a334ec62c68c07ef45f144c77b8ac5c2835bf.zip
qboot-3d3a334ec62c68c07ef45f144c77b8ac5c2835bf.tar.gz
qboot-3d3a334ec62c68c07ef45f144c77b8ac5c2835bf.tar.bz2
setup idt
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--include/bios.h4
-rw-r--r--main.c19
2 files changed, 23 insertions, 0 deletions
diff --git a/include/bios.h b/include/bios.h
index 22a912a..fcfc5ba 100644
--- a/include/bios.h
+++ b/include/bios.h
@@ -31,6 +31,10 @@ extern bioscall void int10_handler(struct biosregs *regs);
extern bioscall void int15_handler(struct biosregs *regs);
extern bioscall void e820_query_map(struct biosregs *regs);
+extern void bios_intfake(void);
+extern void bios_int10(void);
+extern void bios_int15(void);
+
extern struct e820map e820;
static inline void __attribute__((noreturn)) panic(void)
diff --git a/main.c b/main.c
index eeb21fd..ed871df 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,7 @@
#include "bios.h"
#include "pci.h"
#include "string.h"
+#include "segment.h"
#define PCI_VENDOR_ID_INTEL 0x8086
#define PCI_DEVICE_ID_INTEL_82441 0x1237
@@ -37,13 +38,31 @@ static void make_bios_writable(void)
memcpy(low_start, bios_start, 0x10000);
}
+static void set_realmode_int(int vec, void *p)
+{
+ uint16_t *realmode_idt = (uint16_t *) 0;
+ realmode_idt[vec * 2] = flat_to_off16((uintptr_t) p);
+ realmode_idt[vec * 2 + 1] = flat_to_seg16((uintptr_t) p);
+}
+
+static void setup_idt(void)
+{
+ int i;
+ for (i = 0; i < 0x1f; i++)
+ set_realmode_int(i, bios_intfake);
+ set_realmode_int(0x10, bios_int10);
+ set_realmode_int(0x15, bios_int15);
+}
int main(void)
{
make_bios_writable();
+ setup_idt();
// extract_acpi();
+ // extract_e820();
// extract_smbios();
// extract_kernel();
+ // make_bios_readonly();
// boot_linux();
panic();
}