/*1* ESI call stub.2*3* Copyright (C) 2005 Hewlett-Packard Co4* Alex Williamson <[email protected]>5*6* Based on EFI call stub by David Mosberger. The stub is virtually7* identical to the one for EFI phys-mode calls, except that ESI8* calls may have up to 8 arguments, so they get passed to this routine9* through memory.10*11* This stub allows us to make ESI calls in physical mode with interrupts12* turned off. ESI calls may not support calling from virtual mode.13*14* Google for "Extensible SAL specification" for a document describing the15* ESI standard.16*/1718/*19* PSR settings as per SAL spec (Chapter 8 in the "IA-64 System20* Abstraction Layer Specification", revision 2.6e). Note that21* psr.dfl and psr.dfh MUST be cleared, despite what this manual says.22* Otherwise, SAL dies whenever it's trying to do an IA-32 BIOS call23* (the br.ia instruction fails unless psr.dfl and psr.dfh are24* cleared). Fortunately, SAL promises not to touch the floating25* point regs, so at least we don't have to save f2-f127.26*/27#define PSR_BITS_TO_CLEAR \28(IA64_PSR_I | IA64_PSR_IT | IA64_PSR_DT | IA64_PSR_RT | \29IA64_PSR_DD | IA64_PSR_SS | IA64_PSR_RI | IA64_PSR_ED | \30IA64_PSR_DFL | IA64_PSR_DFH)3132#define PSR_BITS_TO_SET \33(IA64_PSR_BN)3435#include <asm/processor.h>36#include <asm/asmmacro.h>3738/*39* Inputs:40* in0 = address of function descriptor of ESI routine to call41* in1 = address of array of ESI parameters42*43* Outputs:44* r8 = result returned by called function45*/46GLOBAL_ENTRY(esi_call_phys)47.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)48alloc loc1=ar.pfs,2,7,8,049ld8 r2=[in0],8 // load ESI function's entry point50mov loc0=rp51.body52;;53ld8 out0=[in1],8 // ESI params loaded from array54;; // passing all as inputs doesn't work55ld8 out1=[in1],856;;57ld8 out2=[in1],858;;59ld8 out3=[in1],860;;61ld8 out4=[in1],862;;63ld8 out5=[in1],864;;65ld8 out6=[in1],866;;67ld8 out7=[in1]68mov loc2=gp // save global pointer69mov loc4=ar.rsc // save RSE configuration70mov ar.rsc=0 // put RSE in enforced lazy, LE mode71;;72ld8 gp=[in0] // load ESI function's global pointer73movl r16=PSR_BITS_TO_CLEAR74mov loc3=psr // save processor status word75movl r17=PSR_BITS_TO_SET76;;77or loc3=loc3,r1778mov b6=r279;;80andcm r16=loc3,r16 // get psr with IT, DT, and RT bits cleared81br.call.sptk.many rp=ia64_switch_mode_phys82.ret0: mov loc5=r19 // old ar.bsp83mov loc6=r20 // old sp84br.call.sptk.many rp=b6 // call the ESI function85.ret1: mov ar.rsc=0 // put RSE in enforced lazy, LE mode86mov r16=loc3 // save virtual mode psr87mov r19=loc5 // save virtual mode bspstore88mov r20=loc6 // save virtual mode sp89br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode90.ret2: mov ar.rsc=loc4 // restore RSE configuration91mov ar.pfs=loc192mov rp=loc093mov gp=loc294br.ret.sptk.many rp95END(esi_call_phys)969798