1/// @file 2/// Contains an implementation of CallPalProcStacked on Itanium-based 3/// architecture. 4/// 5/// Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR> 6/// This program and the accompanying materials 7/// are licensed and made available under the terms and conditions of the BSD License 8/// which accompanies this distribution. The full text of the license may be found at 9/// http://opensource.org/licenses/bsd-license.php. 10/// 11/// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12/// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13/// 14/// Module Name: AsmPalCall.s 15/// 16/// 17 18 19//----------------------------------------------------------------------------- 20//++ 21// AsmPalCall 22// 23// Makes a PAL procedure call. 24// This is function to make a PAL procedure call. Based on the Index 25// value this API will make static or stacked PAL call. The following table 26// describes the usage of PAL Procedure Index Assignment. Architected procedures 27// may be designated as required or optional. If a PAL procedure is specified 28// as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the 29// Status field of the PAL_CALL_RETURN structure. 30// This indicates that the procedure is not present in this PAL implementation. 31// It is the caller's responsibility to check for this return code after calling 32// any optional PAL procedure. 33// No parameter checking is performed on the 5 input parameters, but there are 34// some common rules that the caller should follow when making a PAL call. Any 35// address passed to PAL as buffers for return parameters must be 8-byte aligned. 36// Unaligned addresses may cause undefined results. For those parameters defined 37// as reserved or some fields defined as reserved must be zero filled or the invalid 38// argument return value may be returned or undefined result may occur during the 39// execution of the procedure. If the PalEntryPoint does not point to a valid 40// PAL entry point then the system behavior is undefined. This function is only 41// available on IPF. 42// 43// On Entry : 44// in0: PAL_PROC entrypoint 45// in1-in4 : PAL_PROC arguments 46// 47// Return Value: 48// 49// As per stacked calling conventions. 50// 51//-- 52//--------------------------------------------------------------------------- 53 54// 55// PAL function calls 56// 57#define PAL_MC_CLEAR_LOG 0x0015 58#define PAL_MC_DYNAMIC_STATE 0x0018 59#define PAL_MC_ERROR_INFO 0x0019 60#define PAL_MC_RESUME 0x001a 61 62 63.text 64.proc AsmPalCall 65.type AsmPalCall, @function 66 67AsmPalCall:: 68 alloc loc1 = ar.pfs,5,8,4,0 69 mov loc0 = b0 70 mov loc3 = b5 71 mov loc4 = r2 72 mov loc7 = r1 73 mov r2 = psr;; 74 mov r28 = in1 75 mov loc5 = r2;; 76 77 movl loc6 = 0x100;; 78 cmp.ge p6,p7 = r28,loc6;; 79 80(p6) movl loc6 = 0x1FF;; 81(p7) br.dpnt.few PalCallStatic;; // 0 ~ 255 make a static Pal Call 82(p6) cmp.le p6,p7 = r28,loc6;; 83(p6) br.dpnt.few PalCallStacked;; // 256 ~ 511 make a stacked Pal Call 84(p7) movl loc6 = 0x300;; 85(p7) cmp.ge p6,p7 = r28,loc6;; 86(p7) br.dpnt.few PalCallStatic;; // 512 ~ 767 make a static Pal Call 87(p6) movl loc6 = 0x3FF;; 88(p6) cmp.le p6,p7 = r28,loc6;; 89(p6) br.dpnt.few PalCallStacked;; // 768 ~ 1023 make a stacked Pal Call 90 91(p7) mov r8 = 0xFFFFFFFFFFFFFFFF;; // > 1024 return invalid 92(p7) br.dpnt.few ComeBackFromPALCall;; 93 94PalCallStatic: 95 movl loc6 = PAL_MC_CLEAR_LOG;; 96 cmp.eq p6,p7 = r28,loc6;; 97 98(p7) movl loc6 = PAL_MC_DYNAMIC_STATE;; 99(p7) cmp.eq p6,p7 = r28,loc6;; 100 101(p7) movl loc6 = PAL_MC_ERROR_INFO;; 102(p7) cmp.eq p6,p7 = r28,loc6;; 103 104(p7) movl loc6 = PAL_MC_RESUME;; 105(p7) cmp.eq p6,p7 = r28,loc6 ;; 106 107 mov loc6 = 0x1;; 108(p7) dep r2 = loc6,r2,13,1;; // psr.ic = 1 109 110// p6 will be true, if it is one of the MCHK calls. There has been lots of debate 111// on psr.ic for these values. For now, do not do any thing to psr.ic 112 113 dep r2 = r0,r2,14,1;; // psr.i = 0 114 115 mov psr.l = r2 116 srlz.d // Needs data serailization. 117 srlz.i // Needs instruction serailization. 118 119StaticGetPALLocalIP: 120 mov loc2 = ip;; 121 add loc2 = ComeBackFromPALCall - StaticGetPALLocalIP,loc2;; 122 mov b0 = loc2 // return address after Pal call 123 124 mov r29 = in2 125 mov r30 = in3 126 mov r31 = in4 127 mov b5 = in0;; // get the PalProcEntrypt from input 128 br.sptk b5;; // Take the plunge. 129 130PalCallStacked: 131 dep r2 = r0,r2,14,1;; // psr.i = 0 132 mov psr.l = r2;; 133 srlz.d // Needs data serailization. 134 srlz.i // Needs instruction serailization. 135 136StackedGetPALLocalIP: 137 mov out0 = in1 138 mov out1 = in2 139 mov out2 = in3 140 mov out3 = in4 141 mov b5 = in0 ;; // get the PalProcEntrypt from input 142 br.call.dpnt b0 = b5 ;; // Take the plunge. 143 144ComeBackFromPALCall: 145 mov psr.l = loc5 ;; 146 srlz.d // Needs data serailization. 147 srlz.i // Needs instruction serailization. 148 149 mov b5 = loc3 150 mov r2 = loc4 151 mov r1 = loc7 152 153 mov b0 = loc0 154 mov ar.pfs = loc1;; 155 br.ret.dpnt b0;; 156 157.endp AsmPalCall 158 159