Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *
0004  *  Trampoline.S    Derived from Setup.S by Linus Torvalds
0005  *
0006  *  4 Jan 1997 Michael Chastain: changed to gnu as.
0007  *
0008  *  This is only used for booting secondary CPUs in SMP machine
0009  *
0010  *  Entry: CS:IP point to the start of our code, we are
0011  *  in real mode with no stack, but the rest of the
0012  *  trampoline page to make our stack and everything else
0013  *  is a mystery.
0014  *
0015  *  We jump into arch/x86/kernel/head_32.S.
0016  *
0017  *  On entry to trampoline_start, the processor is in real mode
0018  *  with 16-bit addressing and 16-bit data.  CS has some value
0019  *  and IP is zero.  Thus, we load CS to the physical segment
0020  *  of the real mode code before doing anything further.
0021  */
0022 
0023 #include <linux/linkage.h>
0024 #include <asm/segment.h>
0025 #include <asm/page_types.h>
0026 #include "realmode.h"
0027 
0028     .text
0029     .code16
0030 
0031     .balign PAGE_SIZE
0032 SYM_CODE_START(trampoline_start)
0033     wbinvd          # Needed for NUMA-Q should be harmless for others
0034 
0035     LJMPW_RM(1f)
0036 1:
0037     mov %cs, %ax    # Code and data in the same place
0038     mov %ax, %ds
0039 
0040     cli         # We should be safe anyway
0041 
0042     movl    tr_start, %eax  # where we need to go
0043 
0044     /*
0045      * GDT tables in non default location kernel can be beyond 16MB and
0046      * lgdt will not be able to load the address as in real mode default
0047      * operand size is 16bit. Use lgdtl instead to force operand size
0048      * to 32 bit.
0049      */
0050     lidtl   tr_idt          # load idt with 0, 0
0051     lgdtl   tr_gdt          # load gdt with whatever is appropriate
0052 
0053     movw    $1, %dx         # protected mode (PE) bit
0054     lmsw    %dx         # into protected mode
0055 
0056     ljmpl   $__BOOT_CS, $pa_startup_32
0057 SYM_CODE_END(trampoline_start)
0058 
0059     .section ".text32","ax"
0060     .code32
0061 SYM_CODE_START(startup_32)          # note: also used from wakeup_asm.S
0062     jmp *%eax
0063 SYM_CODE_END(startup_32)
0064 
0065     .bss
0066     .balign 8
0067 SYM_DATA_START(trampoline_header)
0068     SYM_DATA_LOCAL(tr_start,    .space 4)
0069     SYM_DATA_LOCAL(tr_gdt_pad,  .space 2)
0070     SYM_DATA_LOCAL(tr_gdt,      .space 6)
0071 SYM_DATA_END(trampoline_header)
0072     
0073 #include "trampoline_common.S"