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 |
| 32 | movl %eax, 2f # Patch ljmpl instruction |
H. Peter Anvin | 7052fdd | 2007-07-11 12:18:53 -0700 | [diff] [blame] | 33 | |
H. Peter Anvin | 7052fdd | 2007-07-11 12:18:53 -0700 | [diff] [blame] | 34 | movw $__BOOT_DS, %cx |
H. Peter Anvin | 9f259cc | 2007-11-04 17:54:31 -0800 | [diff] [blame] | 35 | xorl %ebx, %ebx # Per the 32-bit boot protocol |
| 36 | xorl %ebp, %ebp # Per the 32-bit boot protocol |
| 37 | xorl %edi, %edi # Per the 32-bit boot protocol |
H. Peter Anvin | 7052fdd | 2007-07-11 12:18:53 -0700 | [diff] [blame] | 38 | |
| 39 | movl %cr0, %edx |
| 40 | orb $1, %dl # Protected mode (PE) bit |
| 41 | movl %edx, %cr0 |
H. Peter Anvin | 7ed1929 | 2007-11-04 17:50:12 -0800 | [diff] [blame] | 42 | jmp 1f # Short jump to serialize on 386/486 |
| 43 | 1: |
H. Peter Anvin | 7052fdd | 2007-07-11 12:18:53 -0700 | [diff] [blame] | 44 | |
| 45 | movw %cx, %ds |
| 46 | movw %cx, %es |
| 47 | movw %cx, %fs |
| 48 | movw %cx, %gs |
| 49 | movw %cx, %ss |
| 50 | |
| 51 | # Jump to the 32-bit entrypoint |
| 52 | .byte 0x66, 0xea # ljmpl opcode |
| 53 | 2: .long 0 # offset |
| 54 | .word __BOOT_CS # segment |
| 55 | |
| 56 | .size protected_mode_jump, .-protected_mode_jump |