2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* 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>
|
2011-05-27 12:46:07 -06:00
|
|
|
#include <asm/desc.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/tlbflush.h>
|
2008-02-13 14:26:39 -07:00
|
|
|
#include <asm/efi.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2008-01-30 05:32:11 -07:00
|
|
|
void efi_call_phys_prelog(void)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-01-30 05:31:12 -07:00
|
|
|
struct desc_ptr gdt_descr;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
local_irq_save(efi_rt_eflags);
|
|
|
|
|
2011-12-08 05:10:50 -07:00
|
|
|
load_cr3(initial_page_table);
|
2008-01-30 05:32:11 -07:00
|
|
|
__flush_tlb_all();
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-05-02 11:27:11 -06:00
|
|
|
gdt_descr.address = __pa(get_cpu_gdt_table(0));
|
|
|
|
gdt_descr.size = GDT_SIZE - 1;
|
|
|
|
load_gdt(&gdt_descr);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2008-01-30 05:32:11 -07:00
|
|
|
void efi_call_phys_epilog(void)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-01-30 05:31:12 -07:00
|
|
|
struct desc_ptr gdt_descr;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-05-02 11:27:11 -06:00
|
|
|
gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
|
|
|
|
gdt_descr.size = GDT_SIZE - 1;
|
|
|
|
load_gdt(&gdt_descr);
|
2006-02-24 14:04:14 -07:00
|
|
|
|
2011-12-08 05:10:50 -07:00
|
|
|
load_cr3(swapper_pg_dir);
|
2008-01-30 05:32:11 -07:00
|
|
|
__flush_tlb_all();
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
local_irq_restore(efi_rt_eflags);
|
|
|
|
}
|