From 7613b42bcd87a414c5fed5197952a0dd3d635654 Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Wed, 25 Oct 2006 20:04:46 +0000 Subject: [PATCH] copy of the original trampoline code, needs to be modified as UNDI needes the used address range git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19125 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../boot/platform/pxe_ia32/smp_trampoline.S | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/system/boot/platform/pxe_ia32/smp_trampoline.S diff --git a/src/system/boot/platform/pxe_ia32/smp_trampoline.S b/src/system/boot/platform/pxe_ia32/smp_trampoline.S new file mode 100644 index 0000000000..480f453b57 --- /dev/null +++ b/src/system/boot/platform/pxe_ia32/smp_trampoline.S @@ -0,0 +1,69 @@ +/* +** Copyright 2001, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ +// expects a stack page like this: +// (stack has to be at (0x9e000) +// 0x9effc : final esp +// 0x9eff8 : page dir +// +// 0x9e000 - 0x9e006 : gdt descriptor +// 0x9e008 - 0x9e020 : gdt +// +// smp_trampoline must be located at 0x9f000 +.globl smp_trampoline +.globl smp_trampoline_end +.globl foo + +.code16 +smp_trampoline: + cli + + mov $0x9e00,%ax + mov %ax,%ds + +// lgdt 0x9e000 # load the gdt +.byte 0x66, 0x0f, 0x01, 0x15, 0x00, 0xe0, 0x09, 0x00 + + movl %cr0,%eax + orl $0x01,%eax + movl %eax,%cr0 # switch into protected mode + +.code32 +_trampoline_32: + .byte 0x66 + ljmp $0x08,$(trampoline_32 - smp_trampoline + 0x9f000) +trampoline_32: + mov $0x10, %ax + mov %ax, %ds + mov %ax, %es + mov %ax, %fs + mov %ax, %gs + mov %ax, %ss + + movl $0x9eff8,%esp # set up the stack pointer + + popl %eax # get the page dir + movl %eax,%cr3 # set the page dir + + popl %eax # get the final stack location + movl %eax,%esp + + // load an address for an indirect jump + movl $trampoline_after_paging,%ecx + + movl %cr0,%eax + orl $0x80000000,%eax + movl %eax,%cr0 # enable paging + + // jump to the address previously loaded. NOTE: + // this address is the address at which the code is originally linked, + // which is > 1MB. We will be out of the low memory at this point. + jmp *%ecx +trampoline_after_paging: + // just return, the bsp would have set the return address to the + // target function at the top of the passed stack + ret + +smp_trampoline_end: +