| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 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 |  * | 
| Pavel Machek | 94a8a7a | 2008-02-04 16:48:01 +0100 | [diff] [blame] | 14 |  *	We jump into arch/x86/kernel/head_32.S. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 |  * | 
 | 16 |  *	On entry to trampoline_data, the processor is in real mode | 
 | 17 |  *	with 16-bit addressing and 16-bit data.  CS has some value | 
 | 18 |  *	and IP is zero.  Thus, data addresses need to be absolute | 
 | 19 |  *	(no relocation) and are taken with regard to r_base. | 
 | 20 |  * | 
 | 21 |  *	If you work on this file, check the object module with | 
 | 22 |  *	objdump --reloc to make sure there are no relocation | 
 | 23 |  *	entries except for: | 
 | 24 |  * | 
 | 25 |  *	TYPE              VALUE | 
 | 26 |  *	R_386_32          startup_32_smp | 
| Sebastien Dugue | 52de74d | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 27 |  *	R_386_32          boot_gdt | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 |  */ | 
 | 29 |  | 
 | 30 | #include <linux/linkage.h> | 
| Jan Beulich | 5f68563 | 2009-09-04 09:16:22 +0100 | [diff] [blame] | 31 | #include <linux/init.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <asm/segment.h> | 
| Jeremy Fitzhardinge | 0341c14 | 2009-02-13 11:14:01 -0800 | [diff] [blame] | 33 | #include <asm/page_types.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 |  | 
| H. Peter Anvin | 4822b7f | 2011-02-14 15:34:57 -0800 | [diff] [blame] | 35 | #ifdef CONFIG_SMP | 
 | 36 |  | 
 | 37 | 	.section ".x86_trampoline","a" | 
 | 38 | 	.balign PAGE_SIZE | 
 | 39 | 	.code16 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 |  | 
 | 41 | ENTRY(trampoline_data) | 
 | 42 | r_base = . | 
 | 43 | 	wbinvd			# Needed for NUMA-Q should be harmless for others | 
 | 44 | 	mov	%cs, %ax	# Code and data in the same place | 
 | 45 | 	mov	%ax, %ds | 
 | 46 |  | 
 | 47 | 	cli			# We should be safe anyway | 
 | 48 |  | 
| H. Peter Anvin | 4822b7f | 2011-02-14 15:34:57 -0800 | [diff] [blame] | 49 | 	movl	$0xA5A5A5A5, trampoline_status - r_base | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | 				# write marker for master knows we're running | 
 | 51 |  | 
 | 52 | 	/* GDT tables in non default location kernel can be beyond 16MB and | 
 | 53 | 	 * lgdt will not be able to load the address as in real mode default | 
 | 54 | 	 * operand size is 16bit. Use lgdtl instead to force operand size | 
 | 55 | 	 * to 32 bit. | 
 | 56 | 	 */ | 
 | 57 |  | 
| Sebastien Dugue | 52de74d | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 58 | 	lidtl	boot_idt_descr - r_base	# load idt with 0, 0 | 
 | 59 | 	lgdtl	boot_gdt_descr - r_base	# load gdt with whatever is appropriate | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 |  | 
 | 61 | 	xor	%ax, %ax | 
 | 62 | 	inc	%ax		# protected mode (PE) bit | 
 | 63 | 	lmsw	%ax		# into protected mode | 
 | 64 | 	# flush prefetch and jump to startup_32_smp in arch/i386/kernel/head.S | 
 | 65 | 	ljmpl	$__BOOT_CS, $(startup_32_smp-__PAGE_OFFSET) | 
 | 66 |  | 
 | 67 | 	# These need to be in the same 64K segment as the above; | 
 | 68 | 	# hence we don't use the boot_gdt_descr defined in head.S | 
| Sebastien Dugue | 52de74d | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 69 | boot_gdt_descr: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | 	.word	__BOOT_DS + 7			# gdt limit | 
| Sebastien Dugue | 52de74d | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 71 | 	.long	boot_gdt - __PAGE_OFFSET	# gdt base | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 |  | 
| Sebastien Dugue | 52de74d | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 73 | boot_idt_descr: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | 	.word	0				# idt limit = 0 | 
 | 75 | 	.long	0				# idt base = 0L | 
 | 76 |  | 
| H. Peter Anvin | 4822b7f | 2011-02-14 15:34:57 -0800 | [diff] [blame] | 77 | ENTRY(trampoline_status) | 
 | 78 | 	.long	0 | 
 | 79 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | .globl trampoline_end | 
 | 81 | trampoline_end: | 
| H. Peter Anvin | 4822b7f | 2011-02-14 15:34:57 -0800 | [diff] [blame] | 82 |  | 
 | 83 | #endif /* CONFIG_SMP */ |