ArmPlatformPkg/ArmPlatformGlobalVariableLib: Added new function ArmPlatformGetGlobalVariableAddress()

This function returns the address of a Global Variable in the Global Variable Region.

Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13246 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2012-05-02 19:51:08 +00:00
parent f437141a9c
commit d9efd68ef5
6 changed files with 63 additions and 6 deletions

View File

@ -1,6 +1,6 @@
/** @file
*
* Copyright (c) 2011, ARM Limited. All rights reserved.
* Copyright (c) 2011-2012, 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
@ -29,5 +29,10 @@ ArmPlatformSetGlobalVariable (
OUT VOID* Variable
);
VOID*
ArmPlatformGetGlobalVariableAddress (
IN UINTN VariableOffset
);
#endif

View File

@ -1,6 +1,6 @@
/** @file
*
* Copyright (c) 2011, ARM Limited. All rights reserved.
* Copyright (c) 2011-2012, 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
@ -67,3 +67,10 @@ ArmPlatformSetGlobalVariable (
CopyMem ((VOID*)(mGlobalVariableBase + VariableOffset), Variable, VariableSize);
}
VOID*
ArmPlatformGetGlobalVariableAddress (
IN UINTN VariableOffset
)
{
return (VOID*)(mGlobalVariableBase + VariableOffset);
}

View File

@ -3,6 +3,7 @@
#
#
# Copyright (c) 2011-2012, 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

View File

@ -43,8 +43,6 @@ ArmPlatformGetGlobalVariable (
} else {
CopyMem (Variable, (VOID*)(GlobalVariableBase + VariableOffset), VariableSize);
}
//DEBUG((EFI_D_ERROR,"++ GET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable));
}
VOID
@ -68,7 +66,19 @@ ArmPlatformSetGlobalVariable (
} else {
CopyMem ((VOID*)(GlobalVariableBase + VariableOffset), Variable, VariableSize);
}
//DEBUG((EFI_D_ERROR,"++ SET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable));
}
VOID*
ArmPlatformGetGlobalVariableAddress (
IN UINTN VariableOffset
)
{
UINTN GlobalVariableBase;
// Ensure the Global Variable Size have been initialized
ASSERT (VariableOffset < PcdGet32 (PcdPeiGlobalVariableSize));
GlobalVariableBase = PcdGet32 (PcdCPUCoresStackBase) + PcdGet32 (PcdCPUCorePrimaryStackSize) - PcdGet32 (PcdPeiGlobalVariableSize);
return (VOID*)(GlobalVariableBase + VariableOffset);
}

View File

@ -83,3 +83,23 @@ ArmPlatformSetGlobalVariable (
}
}
VOID*
ArmPlatformGetGlobalVariableAddress (
IN UINTN VariableOffset
)
{
UINTN GlobalVariableBase;
// Ensure the Global Variable Size have been initialized
ASSERT (VariableOffset < PcdGet32 (PcdPeiGlobalVariableSize));
if (IS_XIP()) {
// In Case of XIP, we expect the Primary Stack at the top of the System Memory
// The size must be 64bit aligned to allow 64bit variable to be aligned
GlobalVariableBase = PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemorySize) - ALIGN_VALUE(PcdGet32 (PcdPeiGlobalVariableSize),0x8);
} else {
GlobalVariableBase = mGlobalVariableBase;
}
return (VOID*)(GlobalVariableBase + VariableOffset);
}

View File

@ -65,3 +65,17 @@ ArmPlatformSetGlobalVariable (
}
}
VOID*
ArmPlatformGetGlobalVariableAddress (
IN UINTN VariableOffset
)
{
UINTN GlobalVariableBase;
// Ensure the Global Variable Size have been initialized
ASSERT (VariableOffset < PcdGet32 (PcdSecGlobalVariableSize));
GlobalVariableBase = PcdGet32 (PcdCPUCoresSecStackBase) + PcdGet32 (PcdCPUCoreSecPrimaryStackSize) - PcdGet32 (PcdSecGlobalVariableSize);
return (VOID*)(GlobalVariableBase + VariableOffset);
}