From e34a3cd87a2654071b14bd8ae97d7cb8841be852 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 9 Jul 2012 20:37:09 +0100 Subject: [setup] Make setup.S position-independent code Derive the base address of the GDT from %cs, in order to allow setup.S to be loaded to any address. Signed-off-by: Michael Brown --- setup.S | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setup.S b/setup.S index 93d34e1..9ae578f 100644 --- a/setup.S +++ b/setup.S @@ -22,8 +22,11 @@ start: outb %al, $0x70 # The system will move itself to its rightful place. - push %cs - pop %ds + xorl %eax, %eax + movw %cs, %ax + movw %ax, %ds + shll $4, %eax + addl %eax, gdt_48 - start + 2 lidt idt_48 - start # load idt with 0,0 lgdt gdt_48 - start # load gdt with whatever appropriate @@ -134,7 +137,7 @@ idt_48: gdt_48: .word 0x800 # gdt limit=2048, 256 GDT entries - .word 512+gdt - start,0x9 # gdt base = 0X9xxxx + .long gdt - start # gdt base msg1: .asciz "Setup.S\r\n" -- cgit v1.2.3-55-g7522