Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* ----------------------------------------------------------------------- *
0003  *
0004  *   Copyright (C) 1991, 1992 Linus Torvalds
0005  *   Copyright 2007 rPath, Inc. - All Rights Reserved
0006  *
0007  * ----------------------------------------------------------------------- */
0008 
0009 /*
0010  * The actual transition into protected mode
0011  */
0012 
0013 #include <asm/boot.h>
0014 #include <asm/processor-flags.h>
0015 #include <asm/segment.h>
0016 #include <linux/linkage.h>
0017 
0018     .text
0019     .code16
0020 
0021 /*
0022  * void protected_mode_jump(u32 entrypoint, u32 bootparams);
0023  */
0024 SYM_FUNC_START_NOALIGN(protected_mode_jump)
0025     movl    %edx, %esi      # Pointer to boot_params table
0026 
0027     xorl    %ebx, %ebx
0028     movw    %cs, %bx
0029     shll    $4, %ebx
0030     addl    %ebx, 2f
0031     jmp 1f          # Short jump to serialize on 386/486
0032 1:
0033 
0034     movw    $__BOOT_DS, %cx
0035     movw    $__BOOT_TSS, %di
0036 
0037     movl    %cr0, %edx
0038     orb $X86_CR0_PE, %dl    # Protected mode
0039     movl    %edx, %cr0
0040 
0041     # Transition to 32-bit mode
0042     .byte   0x66, 0xea      # ljmpl opcode
0043 2:  .long   .Lin_pm32       # offset
0044     .word   __BOOT_CS       # segment
0045 SYM_FUNC_END(protected_mode_jump)
0046 
0047     .code32
0048     .section ".text32","ax"
0049 SYM_FUNC_START_LOCAL_NOALIGN(.Lin_pm32)
0050     # Set up data segments for flat 32-bit mode
0051     movl    %ecx, %ds
0052     movl    %ecx, %es
0053     movl    %ecx, %fs
0054     movl    %ecx, %gs
0055     movl    %ecx, %ss
0056     # The 32-bit code sets up its own stack, but this way we do have
0057     # a valid stack if some debugging hack wants to use it.
0058     addl    %ebx, %esp
0059 
0060     # Set up TR to make Intel VT happy
0061     ltr %di
0062 
0063     # Clear registers to allow for future extensions to the
0064     # 32-bit boot protocol
0065     xorl    %ecx, %ecx
0066     xorl    %edx, %edx
0067     xorl    %ebx, %ebx
0068     xorl    %ebp, %ebp
0069     xorl    %edi, %edi
0070 
0071     # Set up LDTR to make Intel VT happy
0072     lldt    %cx
0073 
0074     jmpl    *%eax           # Jump to the 32-bit entrypoint
0075 SYM_FUNC_END(.Lin_pm32)