3 * Copyright (c) 2011, ARM Limited. All rights reserved.
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
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.
16 #include <Library/ArmPlatformGlobalVariableLib.h>
17 #include <Library/BaseLib.h>
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/PcdLib.h>
22 //#include <Library/DebugLib.h>
25 ArmPlatformGetGlobalVariable (
26 IN UINTN VariableOffset
,
27 IN UINTN VariableSize
,
31 UINTN GlobalVariableBase
;
33 GlobalVariableBase
= PcdGet32 (PcdCPUCoresSecStackBase
) + PcdGet32 (PcdCPUCoreSecPrimaryStackSize
) - PcdGet32 (PcdSecGlobalVariableSize
) + VariableOffset
;
35 if (VariableSize
== 4) {
36 *(UINT32
*)Variable
= ReadUnaligned32 ((CONST UINT32
*)(GlobalVariableBase
+ VariableOffset
));
37 } else if (VariableSize
== 8) {
38 *(UINT32
*)Variable
= ReadUnaligned64 ((CONST UINT64
*)(GlobalVariableBase
+ VariableOffset
));
40 CopyMem (Variable
, (VOID
*)(GlobalVariableBase
+ VariableOffset
), VariableSize
);
43 //DEBUG((EFI_D_ERROR,"++ GET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable));
47 ArmPlatformSetGlobalVariable (
48 IN UINTN VariableOffset
,
49 IN UINTN VariableSize
,
53 UINTN GlobalVariableBase
;
55 GlobalVariableBase
= PcdGet32 (PcdCPUCoresSecStackBase
) + PcdGet32 (PcdCPUCoreSecPrimaryStackSize
) - PcdGet32 (PcdSecGlobalVariableSize
) + VariableOffset
;
57 if (VariableSize
== 4) {
58 WriteUnaligned32 ((UINT32
*)(GlobalVariableBase
+ VariableOffset
), *(UINT32
*)Variable
);
59 } else if (VariableSize
== 8) {
60 WriteUnaligned64 ((UINT64
*)(GlobalVariableBase
+ VariableOffset
), *(UINT64
*)Variable
);
62 CopyMem ((VOID
*)(GlobalVariableBase
+ VariableOffset
), Variable
, VariableSize
);
65 //DEBUG((EFI_D_ERROR,"++ SET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable));