blob: 48ddd76bc4c3d202fe77740bda68a91edd8b1ee2 [file] [log] [blame]
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +03001/*
2 *
3 * Trampoline.S Derived from Setup.S by Linus Torvalds
4 *
5 * 4 Jan 1997 Michael Chastain: changed to gnu as.
6 *
7 * This is only used for booting secondary CPUs in SMP machine
8 *
9 * Entry: CS:IP point to the start of our code, we are
10 * in real mode with no stack, but the rest of the
11 * trampoline page to make our stack and everything else
12 * is a mystery.
13 *
14 * We jump into arch/x86/kernel/head_32.S.
15 *
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030016 * On entry to trampoline_start, the processor is in real mode
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030017 * with 16-bit addressing and 16-bit data. CS has some value
18 * and IP is zero. Thus, we load CS to the physical segment
19 * of the real mode code before doing anything further.
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030020 */
21
22#include <linux/linkage.h>
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030023#include <asm/segment.h>
24#include <asm/page_types.h>
H. Peter Anvine5684ec2012-05-08 21:22:37 +030025#include "realmode.h"
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030026
27 .text
28 .code16
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030029
Jarkko Sakkinen8e029fc2012-05-08 21:22:40 +030030 .balign PAGE_SIZE
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030031ENTRY(trampoline_start)
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030032 wbinvd # Needed for NUMA-Q should be harmless for others
33
H. Peter Anvine5684ec2012-05-08 21:22:37 +030034 LJMPW_RM(1f)
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +0300351:
36 mov %cs, %ax # Code and data in the same place
37 mov %ax, %ds
38
39 cli # We should be safe anyway
40
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030041 movl tr_start, %eax # where we need to go
H. Peter Anvin968ff9e2012-05-08 21:22:36 +030042
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030043 movl $0xA5A5A5A5, trampoline_status
44 # write marker for master knows we're running
45
H. Peter Anvin968ff9e2012-05-08 21:22:36 +030046 /*
47 * GDT tables in non default location kernel can be beyond 16MB and
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030048 * lgdt will not be able to load the address as in real mode default
49 * operand size is 16bit. Use lgdtl instead to force operand size
50 * to 32 bit.
51 */
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030052 lidtl tr_idt # load idt with 0, 0
53 lgdtl tr_gdt # load gdt with whatever is appropriate
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030054
H. Peter Anvin968ff9e2012-05-08 21:22:36 +030055 movw $1, %dx # protected mode (PE) bit
56 lmsw %dx # into protected mode
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030057
H. Peter Anvin968ff9e2012-05-08 21:22:36 +030058 ljmpl $__BOOT_CS, $pa_startup_32
59
60 .section ".text32","ax"
61 .code32
62ENTRY(startup_32) # note: also used from wakeup_asm.S
63 jmp *%eax
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030064
H. Peter Anvin51edbe6a2012-05-16 13:44:10 -070065 .bss
66 .balign 8
67GLOBAL(trampoline_header)
68 tr_start: .space 4
69 tr_gdt_pad: .space 2
70 tr_gdt: .space 6
71END(trampoline_header)
72
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030073#include "trampoline_common.S"