Initial import.
[mirror_edk2.git] / EdkModulePkg / Core / Pei / Ipf / SwitchToCacheMode.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 SwitchToCacheMode.c
15
16 Abstract:
17
18 Ipf CAR specific function used to switch to cache mode for the later memory access
19
20 Revision History
21
22 --*/
23 #include <PeiMain.h>
24 #include "IpfCpuCore.i"
25
26 extern
27 SAL_RETURN_REGS
28 GetHandOffStatus (
29 VOID
30 );
31
32 VOID
33 SwitchToCacheMode (
34 IN PEI_CORE_INSTANCE *CoreData
35 )
36 /*++
37
38 Routine Description:
39
40 Switch the PHIT pointers to cache mode after InstallPeiMemory in CAR.
41
42 Arguments:
43
44 CoreData - The PEI core Private Data
45
46 Returns:
47
48 --*/
49 {
50 EFI_HOB_HANDOFF_INFO_TABLE *Phit;
51
52 if (CoreData == NULL) {
53 //
54 // the first call with CoreData as NULL.
55 //
56 return;
57 }
58
59 if ((GetHandOffStatus().r10 & 0xFF) == RecoveryFn) {
60 CoreData->StackBase = CoreData->StackBase & CACHE_MODE_ADDRESS_MASK;
61 CoreData->HobList.Raw = (UINT8 *)((UINTN)CoreData->HobList.Raw & CACHE_MODE_ADDRESS_MASK);
62
63 //
64 // Change the PHIT pointer value to cache mode
65 //
66 Phit = CoreData->HobList.HandoffInformationTable;
67
68 Phit->EfiMemoryTop = Phit->EfiMemoryTop & CACHE_MODE_ADDRESS_MASK;
69 Phit->EfiFreeMemoryTop = Phit->EfiFreeMemoryTop & CACHE_MODE_ADDRESS_MASK;
70 Phit->EfiMemoryBottom = Phit->EfiMemoryBottom & CACHE_MODE_ADDRESS_MASK;
71 Phit->EfiFreeMemoryBottom = Phit->EfiFreeMemoryBottom & CACHE_MODE_ADDRESS_MASK;
72 Phit->EfiEndOfHobList = Phit->EfiEndOfHobList & CACHE_MODE_ADDRESS_MASK;
73 }
74
75 return;
76 }