summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2012-07-09 21:37:09 +0200
committerMichael Brown2015-04-20 22:30:12 +0200
commite34a3cd87a2654071b14bd8ae97d7cb8841be852 (patch)
tree1ca33779218f6b463335fd47ccaedfbc08f3df15
parent[setup] Revert unused SMP code (diff)
downloadmemtest86-e34a3cd87a2654071b14bd8ae97d7cb8841be852.tar.gz
memtest86-e34a3cd87a2654071b14bd8ae97d7cb8841be852.tar.xz
memtest86-e34a3cd87a2654071b14bd8ae97d7cb8841be852.zip
[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 <mcb30@ipxe.org>
-rw-r--r--setup.S9
1 files 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"