diff options
Diffstat (limited to 'ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe')
2 files changed, 111 insertions, 0 deletions
diff --git a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c new file mode 100644 index 0000000000..aebc912935 --- /dev/null +++ b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c @@ -0,0 +1,69 @@ +/** @file +* +* Copyright (c) 2011, ARM Limited. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the BSD License +* which accompanies this distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +**/ + +#include <PiDxe.h> +#include <Library/ArmPlatformGlobalVariableLib.h> +#include <Library/BaseMemoryLib.h> +#include <Library/DebugLib.h> +#include <Library/HobLib.h> +#include <Library/PcdLib.h> + +#include <Guid/ArmGlobalVariableHob.h> + +UINTN mGlobalVariableBase = 0; + +RETURN_STATUS +EFIAPI +ArmPlatformGlobalVariableConstructor ( + VOID + ) +{ + ARM_HOB_GLOBAL_VARIABLE *Hob; + + Hob = GetFirstGuidHob (&gArmGlobalVariableGuid); + ASSERT (Hob != NULL); + + mGlobalVariableBase = Hob->GlobalVariableBase; + + return EFI_SUCCESS; +} + +VOID +ArmPlatformGetGlobalVariable ( + IN UINTN VariableOffset, + IN UINTN VariableSize, + OUT VOID* Variable + ) +{ + if (mGlobalVariableBase == 0) { + ArmPlatformGlobalVariableConstructor (); + } + + CopyMem (Variable, (VOID*)(mGlobalVariableBase + VariableOffset), VariableSize); +} + +VOID +ArmPlatformSetGlobalVariable ( + IN UINTN VariableOffset, + IN UINTN VariableSize, + OUT VOID* Variable + ) +{ + if (mGlobalVariableBase == 0) { + ArmPlatformGlobalVariableConstructor (); + } + + CopyMem ((VOID*)(mGlobalVariableBase + VariableOffset), Variable, VariableSize); +} + diff --git a/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf new file mode 100644 index 0000000000..a1e9dcf80a --- /dev/null +++ b/ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf @@ -0,0 +1,42 @@ +#/** @file +# Timer library implementation +# +# +# Copyright (c) 2011, ARM Ltd. All rights reserved.<BR> +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = DxeArmPlatformGlobalVariableLib + FILE_GUID = 53fa3cc3-23b7-4ec2-9bfa-30257d7e1135 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = ArmPlatformGlobalVariableLib + + CONSTRUCTOR = ArmPlatformGlobalVariableConstructor + +[Sources.common] + DxeArmPlatformGlobalVariableLib.c + +[Packages] + MdePkg/MdePkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + +[LibraryClasses] + BaseLib + HobLib + +[Guids] + gArmGlobalVariableGuid + +[FixedPcd] + gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize + |