efi_32.c 2.1 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
 * Extensible Firmware Interface
 *
 * Based on Extensible Firmware Interface Specification version 1.0
 *
 * Copyright (C) 1999 VA Linux Systems
 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
 * Copyright (C) 1999-2002 Hewlett-Packard Co.
 *	David Mosberger-Tang <davidm@hpl.hp.com>
 *	Stephane Eranian <eranian@hpl.hp.com>
 *
 * All EFI Runtime Services are not implemented yet as EFI only
 * supports physical mode addressing on SoftSDV. This is to be fixed
 * in a future version.  --drummond 1999-07-20
 *
 * Implemented EFI runtime services and virtual mode calls.  --davidm
 *
 * Goutham Rao: <goutham.rao@intel.com>
 *	Skip non-WB memory and ignore empty memory ranges.
 */

#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/ioport.h>
#include <linux/efi.h>

#include <asm/io.h>
28
#include <asm/desc.h>
L
Linus Torvalds 已提交
29 30 31
#include <asm/page.h>
#include <asm/pgtable.h>
#include <asm/tlbflush.h>
H
Harvey Harrison 已提交
32
#include <asm/efi.h>
L
Linus Torvalds 已提交
33 34 35 36 37 38 39 40 41

/*
 * To make EFI call EFI runtime service in physical addressing mode we need
 * prelog/epilog before/after the invocation to disable interrupt, to
 * claim EFI runtime service handler exclusively and to duplicate a memory in
 * low memory space say 0 - 3G.
 */
static unsigned long efi_rt_eflags;

42 43 44 45 46 47 48 49
void efi_sync_low_kernel_mappings(void) {}
void efi_setup_page_tables(void) {}

void __init efi_map_region(efi_memory_desc_t *md)
{
	old_map_region(md);
}

50
void __init efi_map_region_fixed(efi_memory_desc_t *md) {}
51
void __init parse_efi_setup(u64 phys_addr, u32 data_len) {}
52

53
void efi_call_phys_prelog(void)
L
Linus Torvalds 已提交
54
{
55
	struct desc_ptr gdt_descr;
L
Linus Torvalds 已提交
56 57 58

	local_irq_save(efi_rt_eflags);

59
	load_cr3(initial_page_table);
60
	__flush_tlb_all();
L
Linus Torvalds 已提交
61

R
Rusty Russell 已提交
62 63 64
	gdt_descr.address = __pa(get_cpu_gdt_table(0));
	gdt_descr.size = GDT_SIZE - 1;
	load_gdt(&gdt_descr);
L
Linus Torvalds 已提交
65 66
}

67
void efi_call_phys_epilog(void)
L
Linus Torvalds 已提交
68
{
69
	struct desc_ptr gdt_descr;
L
Linus Torvalds 已提交
70

R
Rusty Russell 已提交
71 72 73
	gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
	gdt_descr.size = GDT_SIZE - 1;
	load_gdt(&gdt_descr);
74

75
	load_cr3(swapper_pg_dir);
76
	__flush_tlb_all();
L
Linus Torvalds 已提交
77 78 79

	local_irq_restore(efi_rt_eflags);
}
B
Borislav Petkov 已提交
80 81 82 83 84 85

void __init efi_runtime_mkexec(void)
{
	if (__supported_pte_mask & _PAGE_NX)
		runtime_code_page_mkexec();
}