^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * EFI call stub.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 1999-2001 Hewlett-Packard Co
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * David Mosberger <davidm@hpl.hp.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This stub allows us to make EFI calls in physical mode with interrupts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * turned off. We need this because we can't call SetVirtualMap() until
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * the kernel has booted far enough to allow allocation of struct vma_struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * entries (which we would need to map stuff with memory attributes other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * than uncached or writeback...). Since the GetTime() service gets called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * earlier than that, we need to be able to make physical mode EFI calls from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * PSR settings as per SAL spec (Chapter 8 in the "IA-64 System
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * Abstraction Layer Specification", revision 2.6e). Note that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * psr.dfl and psr.dfh MUST be cleared, despite what this manual says.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Otherwise, SAL dies whenever it's trying to do an IA-32 BIOS call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * (the br.ia instruction fails unless psr.dfl and psr.dfh are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * cleared). Fortunately, SAL promises not to touch the floating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * point regs, so at least we don't have to save f2-f127.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define PSR_BITS_TO_CLEAR \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) (IA64_PSR_I | IA64_PSR_IT | IA64_PSR_DT | IA64_PSR_RT | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) IA64_PSR_DD | IA64_PSR_SS | IA64_PSR_RI | IA64_PSR_ED | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) IA64_PSR_DFL | IA64_PSR_DFH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define PSR_BITS_TO_SET \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) (IA64_PSR_BN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <asm/processor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <asm/asmmacro.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * Inputs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * in0 = address of function descriptor of EFI routine to call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * in1..in7 = arguments to routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * Outputs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * r8 = EFI_STATUS returned by called function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) GLOBAL_ENTRY(efi_call_phys)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) alloc loc1=ar.pfs,8,7,7,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) ld8 r2=[in0],8 // load EFI function's entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) mov loc0=rp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) .body
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) mov loc2=gp // save global pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) mov loc4=ar.rsc // save RSE configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) mov ar.rsc=0 // put RSE in enforced lazy, LE mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ld8 gp=[in0] // load EFI function's global pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) movl r16=PSR_BITS_TO_CLEAR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) mov loc3=psr // save processor status word
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) movl r17=PSR_BITS_TO_SET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) or loc3=loc3,r17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) mov b6=r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) andcm r16=loc3,r16 // get psr with IT, DT, and RT bits cleared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) br.call.sptk.many rp=ia64_switch_mode_phys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) .ret0: mov out4=in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) mov out0=in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) mov out1=in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) mov out2=in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) mov out3=in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) mov out5=in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) mov out6=in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) mov loc5=r19
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) mov loc6=r20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) br.call.sptk.many rp=b6 // call the EFI function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) .ret1: mov ar.rsc=0 // put RSE in enforced lazy, LE mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) mov r16=loc3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) mov r19=loc5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) mov r20=loc6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) .ret2: mov ar.rsc=loc4 // restore RSE configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) mov ar.pfs=loc1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) mov rp=loc0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) mov gp=loc2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) br.ret.sptk.many rp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) END(efi_call_phys)