H. Peter Anvin | 7052fdd | 2007-07-11 12:18:53 -0700 | [diff] [blame] | 1 | /* ----------------------------------------------------------------------- * |
| 2 | * |
| 3 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 4 | * Copyright 2007 rPath, Inc. - All Rights Reserved |
| 5 | * |
| 6 | * This file is part of the Linux kernel, and is made available under |
| 7 | * the terms of the GNU General Public License version 2. |
| 8 | * |
| 9 | * ----------------------------------------------------------------------- */ |
| 10 | |
| 11 | /* |
| 12 | * arch/i386/boot/pmjump.S |
| 13 | * |
| 14 | * The actual transition into protected mode |
| 15 | */ |
| 16 | |
| 17 | #include <asm/boot.h> |
| 18 | #include <asm/segment.h> |
| 19 | |
| 20 | .text |
| 21 | |
| 22 | .globl protected_mode_jump |
| 23 | .type protected_mode_jump, @function |
| 24 | |
| 25 | .code16 |
| 26 | |
| 27 | /* |
| 28 | * void protected_mode_jump(u32 entrypoint, u32 bootparams); |
| 29 | */ |
| 30 | protected_mode_jump: |
H. Peter Anvin | 7052fdd | 2007-07-11 12:18:53 -0700 | [diff] [blame] | 31 | movl %edx, %esi # Pointer to boot_params table |
H. Peter Anvin | c4d9ba6 | 2008-01-30 13:33:01 +0100 | [diff] [blame^] | 32 | |
| 33 | xorl %ebx, %ebx |
| 34 | movw %cs, %bx |
| 35 | shll $4, %ebx |
| 36 | addl %ebx, 2f |
H. Peter Anvin | 7052fdd | 2007-07-11 12:18:53 -0700 | [diff] [blame] | 37 | |
H. Peter Anvin | 7052fdd | 2007-07-11 12:18:53 -0700 | [diff] [blame] | 38 | movw $__BOOT_DS, %cx |
| 39 | |
| 40 | movl %cr0, %edx |
| 41 | orb $1, %dl # Protected mode (PE) bit |
| 42 | movl %edx, %cr0 |
H. Peter Anvin | 7ed1929 | 2007-11-04 17:50:12 -0800 | [diff] [blame] | 43 | jmp 1f # Short jump to serialize on 386/486 |
| 44 | 1: |
H. Peter Anvin | 7052fdd | 2007-07-11 12:18:53 -0700 | [diff] [blame] | 45 | |
H. Peter Anvin | c4d9ba6 | 2008-01-30 13:33:01 +0100 | [diff] [blame^] | 46 | # Transition to 32-bit mode |
H. Peter Anvin | 7052fdd | 2007-07-11 12:18:53 -0700 | [diff] [blame] | 47 | .byte 0x66, 0xea # ljmpl opcode |
H. Peter Anvin | c4d9ba6 | 2008-01-30 13:33:01 +0100 | [diff] [blame^] | 48 | 2: .long in_pm32 # offset |
H. Peter Anvin | 7052fdd | 2007-07-11 12:18:53 -0700 | [diff] [blame] | 49 | .word __BOOT_CS # segment |
| 50 | |
| 51 | .size protected_mode_jump, .-protected_mode_jump |
H. Peter Anvin | c4d9ba6 | 2008-01-30 13:33:01 +0100 | [diff] [blame^] | 52 | |
| 53 | .code32 |
| 54 | .type in_pm32, @function |
| 55 | in_pm32: |
| 56 | # Set up data segments for flat 32-bit mode |
| 57 | movl %ecx, %ds |
| 58 | movl %ecx, %es |
| 59 | movl %ecx, %fs |
| 60 | movl %ecx, %gs |
| 61 | movl %ecx, %ss |
| 62 | # The 32-bit code sets up its own stack, but this way we do have |
| 63 | # a valid stack if some debugging hack wants to use it. |
| 64 | addl %ebx, %esp |
| 65 | |
| 66 | # Clear registers to allow for future extensions to the |
| 67 | # 32-bit boot protocol |
| 68 | xorl %ecx, %ecx |
| 69 | xorl %edx, %edx |
| 70 | xorl %ebx, %ebx |
| 71 | xorl %ebp, %ebp |
| 72 | xorl %edi, %edi |
| 73 | |
| 74 | jmpl *%eax # Jump to the 32-bit entrypoint |
| 75 | |
| 76 | .size in_pm32, .-in_pm32 |