/*1* EFI call stub.2*3* Copyright (C) 1999-2001 Hewlett-Packard Co4* David Mosberger <[email protected]>5*6* This stub allows us to make EFI calls in physical mode with interrupts7* turned off. We need this because we can't call SetVirtualMap() until8* the kernel has booted far enough to allow allocation of struct vma_struct9* entries (which we would need to map stuff with memory attributes other10* than uncached or writeback...). Since the GetTime() service gets called11* earlier than that, we need to be able to make physical mode EFI calls from12* the kernel.13*/1415/*16* PSR settings as per SAL spec (Chapter 8 in the "IA-64 System17* Abstraction Layer Specification", revision 2.6e). Note that18* psr.dfl and psr.dfh MUST be cleared, despite what this manual says.19* Otherwise, SAL dies whenever it's trying to do an IA-32 BIOS call20* (the br.ia instruction fails unless psr.dfl and psr.dfh are21* cleared). Fortunately, SAL promises not to touch the floating22* point regs, so at least we don't have to save f2-f127.23*/24#define PSR_BITS_TO_CLEAR \25(IA64_PSR_I | IA64_PSR_IT | IA64_PSR_DT | IA64_PSR_RT | \26IA64_PSR_DD | IA64_PSR_SS | IA64_PSR_RI | IA64_PSR_ED | \27IA64_PSR_DFL | IA64_PSR_DFH)2829#define PSR_BITS_TO_SET \30(IA64_PSR_BN)3132#include <asm/processor.h>33#include <asm/asmmacro.h>3435/*36* Inputs:37* in0 = address of function descriptor of EFI routine to call38* in1..in7 = arguments to routine39*40* Outputs:41* r8 = EFI_STATUS returned by called function42*/4344GLOBAL_ENTRY(efi_call_phys)45.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8)46alloc loc1=ar.pfs,8,7,7,047ld8 r2=[in0],8 // load EFI function's entry point48mov loc0=rp49.body50;;51mov loc2=gp // save global pointer52mov loc4=ar.rsc // save RSE configuration53mov ar.rsc=0 // put RSE in enforced lazy, LE mode54;;55ld8 gp=[in0] // load EFI function's global pointer56movl r16=PSR_BITS_TO_CLEAR57mov loc3=psr // save processor status word58movl r17=PSR_BITS_TO_SET59;;60or loc3=loc3,r1761mov b6=r262;;63andcm r16=loc3,r16 // get psr with IT, DT, and RT bits cleared64br.call.sptk.many rp=ia64_switch_mode_phys65.ret0: mov out4=in566mov out0=in167mov out1=in268mov out2=in369mov out3=in470mov out5=in671mov out6=in772mov loc5=r1973mov loc6=r2074br.call.sptk.many rp=b6 // call the EFI function75.ret1: mov ar.rsc=0 // put RSE in enforced lazy, LE mode76mov r16=loc377mov r19=loc578mov r20=loc679br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode80.ret2: mov ar.rsc=loc4 // restore RSE configuration81mov ar.pfs=loc182mov rp=loc083mov gp=loc284br.ret.sptk.many rp85END(efi_call_phys)868788