arch/x86/boot/startup/efi-mixed.S

Source file repositories/reference/linux-study-clean/arch/x86/boot/startup/efi-mixed.S

File Facts

System
Linux kernel
Corpus path
arch/x86/boot/startup/efi-mixed.S
Extension
.S
Size
6184 bytes
Lines
254
Domain
Architecture Layer
Bucket
arch/x86
Inferred role
Architecture Layer: arch/x86
Status
atlas-only

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#include <linux/linkage.h>
#include <asm/desc_defs.h>
#include <asm/msr.h>
#include <asm/page_types.h>
#include <asm/pgtable_types.h>
#include <asm/processor-flags.h>
#include <asm/segment.h>

	.text
	.code32
#ifdef CONFIG_EFI_HANDOVER_PROTOCOL
SYM_FUNC_START(efi32_stub_entry)
	call	1f
1:	popl	%ecx

	/* Clear BSS */
	xorl	%eax, %eax
	leal	(_bss - 1b)(%ecx), %edi
	leal	(_ebss - 1b)(%ecx), %ecx
	subl	%edi, %ecx
	shrl	$2, %ecx
	cld
	rep	stosl

	add	$0x4, %esp		/* Discard return address */
	movl	8(%esp), %ebx		/* struct boot_params pointer */
	jmp	efi32_startup
SYM_FUNC_END(efi32_stub_entry)
#endif

/*
 * Called using a far call from __efi64_thunk() below, using the x86_64 SysV
 * ABI (except for R8/R9 which are inaccessible to 32-bit code - EAX/EBX are
 * used instead).  EBP+16 points to the arguments passed via the stack.
 *
 * The first argument (EDI) is a pointer to the boot service or protocol, to
 * which the remaining arguments are passed, each truncated to 32 bits.
 */
SYM_FUNC_START_LOCAL(efi_enter32)
	/*
	 * Convert x86-64 SysV ABI params to i386 ABI
	 */
	pushl	32(%ebp)	/* Up to 3 args passed via the stack */
	pushl	24(%ebp)
	pushl	16(%ebp)
	pushl	%ebx		/* R9 */
	pushl	%eax		/* R8 */
	pushl	%ecx
	pushl	%edx
	pushl	%esi

	/* Disable paging */
	movl	%cr0, %eax
	btrl	$X86_CR0_PG_BIT, %eax
	movl	%eax, %cr0

	/* Disable long mode via EFER */
	movl	$MSR_EFER, %ecx
	rdmsr
	btrl	$_EFER_LME, %eax
	wrmsr

	call	*%edi

	/* We must preserve return value */
	movl	%eax, %edi

	call	efi32_enable_long_mode

	addl	$32, %esp

Annotation

Implementation Notes