xref: /OK3568_Linux_fs/u-boot/arch/x86/cpu/call32.S (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun/*
2*4882a593Smuzhiyun * (C) Copyright 2015 Google, Inc
3*4882a593Smuzhiyun * Written by Simon Glass <sjg@chromium.org>
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * SPDX-License-Identifier:	GPL-2.0+
6*4882a593Smuzhiyun */
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun#include <asm/global_data.h>
9*4882a593Smuzhiyun#include <asm/msr-index.h>
10*4882a593Smuzhiyun#include <asm/processor-flags.h>
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun	/*
13*4882a593Smuzhiyun	 * rdi - 32-bit code segment selector
14*4882a593Smuzhiyun	 * rsi - target address
15*4882a593Smuzhiyun	 * rdx - table address (0 if none)
16*4882a593Smuzhiyun	 */
17*4882a593Smuzhiyun.code64
18*4882a593Smuzhiyun.globl cpu_call32
19*4882a593Smuzhiyuncpu_call32:
20*4882a593Smuzhiyun	cli
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun	/* Save table pointer */
23*4882a593Smuzhiyun	mov	%edx, %ebx
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun	/*
26*4882a593Smuzhiyun	 * Debugging option, this outputs characters to the console UART
27*4882a593Smuzhiyun	 * mov	$0x3f8,%edx
28*4882a593Smuzhiyun	 * mov	$'a',%al
29*4882a593Smuzhiyun	 * out	%al,(%dx)
30*4882a593Smuzhiyun	 */
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun	pushf
33*4882a593Smuzhiyun	push	%rdi	/* 32-bit code segment */
34*4882a593Smuzhiyun	lea	compat(%rip), %rax
35*4882a593Smuzhiyun	push	%rax
36*4882a593Smuzhiyun	.byte	0x48	/* REX prefix to force 64-bit far return */
37*4882a593Smuzhiyun	retf
38*4882a593Smuzhiyun.code32
39*4882a593Smuzhiyuncompat:
40*4882a593Smuzhiyun	/*
41*4882a593Smuzhiyun	 * We are now in compatibility mode with a default operand size of
42*4882a593Smuzhiyun	 * 32 bits. First disable paging.
43*4882a593Smuzhiyun	 */
44*4882a593Smuzhiyun	movl	%cr0, %eax
45*4882a593Smuzhiyun	andl	$~X86_CR0_PG, %eax
46*4882a593Smuzhiyun	movl	%eax, %cr0
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun	/* Invalidate TLB */
49*4882a593Smuzhiyun	xorl	%eax, %eax
50*4882a593Smuzhiyun	movl	%eax, %cr3
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun	/* Disable Long mode in EFER (Extended Feature Enable Register) */
53*4882a593Smuzhiyun	movl	$MSR_EFER, %ecx
54*4882a593Smuzhiyun	rdmsr
55*4882a593Smuzhiyun	btr	$_EFER_LME, %eax
56*4882a593Smuzhiyun	wrmsr
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun	/* Set up table pointer for _x86boot_start */
59*4882a593Smuzhiyun	mov	%ebx, %ecx
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun	/* Jump to the required target */
62*4882a593Smuzhiyun	pushl	%edi	/* 32-bit code segment */
63*4882a593Smuzhiyun	pushl	%esi	/* 32-bit target address */
64*4882a593Smuzhiyun	retf
65