2 // Include common header file for this module.
4 #include "CommonHeader.h"
7 // Copyright (c) 2006, Intel Corporation
8 // All rights reserved. This program and the accompanying materials
9 // are licensed and made available under the terms and conditions of the BSD License
10 // which accompanies this distribution. The full text of the license may be found at
11 // http://opensource.org/licenses/bsd-license.php
13 // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 // IPF Specific assembly routines
28 #include "Ipf/IpfCpuCore.i"
30 //----------------------------------------------------------------------------------
31 // This module supports terminating CAR (Cache As RAM) stage. It copies all the
32 // CAR data into real RAM and then makes a stack switch.
36 // IN VOID *EntryPoint,
40 // IN UINTN NewSP, OPTIONAL
41 // IN UINTN NewBSP OPTIONAL
45 // IN VOID *EntryPointForContinuationFunction,
46 // IN UINTN StartupDescriptor,
47 // IN VOID PEICorePointer,
50 //----------------------------------------------------------------------------------
51 PROCEDURE_ENTRY (SwitchCoreStacks)
53 NESTED_SETUP (4,2,0,0)
55 // first save all stack registers in GPRs.
56 mov r13 = in0;; // this is a pointer to the PLABEL of the continuation function.
57 ld8 r16 = [r13],8;; // r16 = address of continuation function from the PLABEL
58 ld8 gp = [r13];; // gp = gp of continuation function from the PLABEL
61 // save the parameters in r5, r6. these 2 seemed to be preserved across PAL calls
62 mov r5 = in1;; // this is the parameter1 to pass to the continuation function
63 mov r6 = in2;; // this is the parameter2 to pass to the continuation function
64 dep r6=0,r6,63,1;; // zero the bit 63.
66 mov r8 = in3;; // new stack pointer.
68 // r8 has the sp, this is 128K stack size, from this we will reserve 16K for the bspstore
69 movl r15 = PEI_BSP_STORE_SIZE;;
71 add r15 = (GuardBand),r8;; // some little buffer, now r15 will be our bspstore
73 // save the bspstore value to r4, save sp value to r7
76 mov r16 = r8;; // will be the new sp in uncache mode
79 alloc r11=0,0,0,0;; // Set 0-size frame
82 mov r21 = RSC_KERNEL_DISABLED;; // for rse disable
83 mov ar.rsc = r21;; // turn off RSE
85 add sp = r0, r16 // transfer to the EFI stack
86 mov ar.bspstore = r15 // switch to EFI BSP
87 invala // change of ar.bspstore needs invala.
89 mov r19 = RSC_KERNEL_LAZ;; // RSC enabled, Lazy mode
90 mov ar.rsc = r19;; // turn rse on, in kernel mode
92 //-----------------------------------------------------------------------------------
93 // Save here the meaningful stuff for next few lines and then make the PAL call.
94 // Make PAL call to terminate the CAR status.
95 // AVL: do this only for recovery check call...
98 dep r2 = r28,r0,0,8;; // Extract Function bits from GR20.
99 cmp.eq p6,p7 = RecoveryFn,r2;; // Is it Recovery check
100 (p7) br.sptk.few DoneCARTermination; // if not, don't terminate car..
105 add r28 = (DoneCARTerminationPALCall - TerminateCAR),r28;;
116 br.sptk.few b6;; // Call PAL-A call.
118 DoneCARTerminationPALCall::
120 // don't check error in soft sdv, it is always returning -1 for this call for some reason
124 cmp.eq p6,p7 = r8,r0;;
126 // dead loop if the PAL call failed, we have the CAR on but the stack is now pointing to memory
128 (p7) br.sptk.few ReturnToPEIMain;;
130 // PAL call successed,now the stack are in memory so come into cache mode
131 // instead of uncache mode
134 alloc r11=0,0,0,0;; // Set 0-size frame
137 mov r21 = RSC_KERNEL_DISABLED;; // for rse disable
138 mov ar.rsc = r21;; // turn off RSE
140 dep r6 = 0,r6,63,1 // zero the bit 63
141 dep r7 = 0,r7,63,1 // zero the bit 63
142 dep r4 = 0,r4,63,1;; // zero the bit 63
143 add sp = r0, r7 // transfer to the EFI stack in cache mode
144 mov ar.bspstore = r4 // switch to EFI BSP
145 invala // change of ar.bspstore needs invala.
147 mov r19 = RSC_KERNEL_LAZ;; // RSC enabled, Lazy mode
148 mov ar.rsc = r19;; // turn rse on, in kernel mode
154 // allocate a stack frame:
155 alloc r11=0,2,2,0 ;; // alloc outs going to ensuing DXE IPL service
162 br.call.sptk.few b0=b6;; // Call the continuation function
166 PROCEDURE_EXIT(SwitchCoreStacks)
167 //-----------------------------------------------------------------------------------
169 //---------------------------------------------------------------------------------
173 // This routine is called by all processors simultaneously, to get some hand-off
174 // status that has been captured by IPF dispatcher and recorded in kernel registers.
180 // Return Value: Lid, R20Status.
183 //----------------------------------------------------------------------------------
184 PROCEDURE_ENTRY (GetHandOffStatus)
186 NESTED_SETUP (0,2+0,0,0)
188 mov r8 = ar.k6 // Health Status (Self test params)
189 mov r9 = ar.k4 // LID bits
190 mov r10 = ar.k3;; // SAL_E entry state
191 mov r11 = ar.k7 // Return address to PAL
194 PROCEDURE_EXIT (GetHandOffStatus)
195 //----------------------------------------------------------------------------------