]>
Commit | Line | Data |
---|---|---|
8fc38a3f | 1 | /** @file |
2 | * | |
3 | * Copyright (c) 2011, ARM Limited. All rights reserved. | |
4 | * | |
5 | * This program and the accompanying materials | |
6 | * are licensed and made available under the terms and conditions of the BSD License | |
7 | * which accompanies this distribution. The full text of the license may be found at | |
8 | * http://opensource.org/licenses/bsd-license.php | |
9 | * | |
10 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | |
11 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | |
12 | * | |
13 | **/ | |
14 | ||
15 | #include <Uefi.h> | |
16 | #include <Library/ArmPlatformGlobalVariableLib.h> | |
17 | #include <Library/BaseLib.h> | |
18 | #include <Library/BaseMemoryLib.h> | |
19 | #include <Library/PcdLib.h> | |
20 | ||
21 | //TODO: RemoveMe | |
22 | //#include <Library/DebugLib.h> | |
23 | ||
24 | // Declared by ArmPlatformPkg/PrePi Module | |
25 | extern UINTN mGlobalVariableBase; | |
26 | ||
27 | VOID | |
28 | ArmPlatformGetGlobalVariable ( | |
29 | IN UINTN VariableOffset, | |
30 | IN UINTN VariableSize, | |
31 | OUT VOID* Variable | |
32 | ) | |
33 | { | |
34 | UINTN GlobalVariableBase; | |
35 | ||
36 | GlobalVariableBase = PcdGet32 (PcdCPUCoresStackBase) + PcdGet32 (PcdCPUCorePrimaryStackSize) - PcdGet32 (PcdPeiGlobalVariableSize) + VariableOffset; | |
37 | ||
38 | if (VariableSize == 4) { | |
39 | *(UINT32*)Variable = ReadUnaligned32 ((CONST UINT32*)(GlobalVariableBase + VariableOffset)); | |
40 | } else if (VariableSize == 8) { | |
41 | *(UINT32*)Variable = ReadUnaligned64 ((CONST UINT64*)(GlobalVariableBase + VariableOffset)); | |
42 | } else { | |
43 | CopyMem (Variable, (VOID*)(GlobalVariableBase + VariableOffset), VariableSize); | |
44 | } | |
45 | ||
46 | //DEBUG((EFI_D_ERROR,"++ GET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable)); | |
47 | } | |
48 | ||
49 | VOID | |
50 | ArmPlatformSetGlobalVariable ( | |
51 | IN UINTN VariableOffset, | |
52 | IN UINTN VariableSize, | |
53 | OUT VOID* Variable | |
54 | ) | |
55 | { | |
56 | UINTN GlobalVariableBase; | |
57 | ||
58 | GlobalVariableBase = PcdGet32 (PcdCPUCoresStackBase) + PcdGet32 (PcdCPUCorePrimaryStackSize) - PcdGet32 (PcdPeiGlobalVariableSize) + VariableOffset; | |
59 | ||
60 | if (VariableSize == 4) { | |
61 | WriteUnaligned32 ((UINT32*)(GlobalVariableBase + VariableOffset), *(UINT32*)Variable); | |
62 | } else if (VariableSize == 8) { | |
63 | WriteUnaligned64 ((UINT64*)(GlobalVariableBase + VariableOffset), *(UINT64*)Variable); | |
64 | } else { | |
65 | CopyMem ((VOID*)(GlobalVariableBase + VariableOffset), Variable, VariableSize); | |
66 | } | |
67 | ||
68 | //DEBUG((EFI_D_ERROR,"++ SET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable)); | |
69 | } | |
70 |