diff options
author | Juergen Beisert <jbe@pengutronix.de> | 2010-01-12 11:15:41 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2010-01-14 10:06:16 +0100 |
commit | 7dcc15e8197e647abc80b1d3298a91edd45a8c2d (patch) | |
tree | f0bb5981a61c989ce37d40554971b9adc49e2b3e /arch/x86/boot/pmjump.S | |
parent | 2bdd75bd02f3d214b285429be72b3a0eab4e9610 (diff) | |
download | barebox-7dcc15e8197e647abc80b1d3298a91edd45a8c2d.tar.gz barebox-7dcc15e8197e647abc80b1d3298a91edd45a8c2d.tar.xz |
Add functions to be able to boot with BIOSs help
These functions are special: They are running in the 16 bit real mode world
to bring up barebox on an x86 box.
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/x86/boot/pmjump.S')
-rw-r--r-- | arch/x86/boot/pmjump.S | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/arch/x86/boot/pmjump.S b/arch/x86/boot/pmjump.S new file mode 100644 index 0000000000..d48e1983f1 --- /dev/null +++ b/arch/x86/boot/pmjump.S @@ -0,0 +1,89 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright (C) 1991, 1992 Linus Torvalds + * Copyright 2007 rPath, Inc. - All Rights Reserved + * + * This file is part of the Linux kernel, and is made available under + * the terms of the GNU General Public License version 2. + * + * ----------------------------------------------------------------------- */ + +/** + * @file + * @brief The actual transition into protected mode + * + * Note: This function is running in flat and real mode. Due to some + * other restrictions it must running from an address space below 0x10000 + */ + +/** + * @fn void protected_mode_jump(void) + * @brief Switches the first time from real mode to flat mode + */ +#ifndef DOXYGEN_SHOULD_SKIP_THIS + +#include <asm/modes.h> +#include "boot.h" + + .file "pmjump.S" + .code16 + .section .boot.text.protected_mode_jump, "ax" + + .globl protected_mode_jump + .type protected_mode_jump, @function + +protected_mode_jump: + jmp 1f /* Short jump to serialize on 386/486 */ +1: + + movw $__BOOT_DS, %cx + movw $__BOOT_TSS, %di + + movl %cr0, %edx + orb $X86_CR0_PE, %dl /* enable protected mode */ + movl %edx, %cr0 + + /* Transition to 32-bit flat mode */ + data32 ljmp $__BOOT_CS, $in_pm32 + +/* ------------------------------------------------------------------------ */ + + .section ".text.in_pm32","ax" + .code32 + + .extern uboot_entry + .extern __bss_end + + .type in_pm32, @function +in_pm32: + # Set up data segments for flat 32-bit mode + movl %ecx, %ds + movl %ecx, %es + movl %ecx, %fs + movl %ecx, %gs + movl %ecx, %ss +/* + * Our flat mode code uses its own stack area behind the bss. With this we + * are still able to return to real mode temporarely + */ + movl $__bss_end + 32768, %esp + + # Set up TR to make Intel VT happy + ltr %di + + # Clear registers to allow for future extensions to the + # 32-bit boot protocol + xorl %ecx, %ecx + xorl %edx, %edx + xorl %ebx, %ebx + xorl %ebp, %ebp + xorl %edi, %edi + + # Set up LDTR to make Intel VT happy + lldt %cx + + jmp uboot_entry + + .size protected_mode_jump, .-protected_mode_jump + +#endif |