Skip to content

Commit

Permalink
ArmPlatformPkg/ArmPlatformGlobalVariableLib: Added new function ArmPl…
Browse files Browse the repository at this point in the history
…atformGetGlobalVariableAddress()

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

Signed-off-by: Olivier Martin <[email protected]>



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13246 6f19259b-4bc3-4df7-8a09-765794883524
  • Loading branch information
oliviermartin committed May 2, 2012
1 parent f437141 commit d9efd68
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -29,5 +29,10 @@ ArmPlatformSetGlobalVariable (
OUT VOID* Variable
);

VOID*
ArmPlatformGetGlobalVariableAddress (
IN UINTN VariableOffset
);

#endif

Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -67,3 +67,10 @@ ArmPlatformSetGlobalVariable (
CopyMem ((VOID*)(mGlobalVariableBase + VariableOffset), Variable, VariableSize);
}

VOID*
ArmPlatformGetGlobalVariableAddress (
IN UINTN VariableOffset
)
{
return (VOID*)(mGlobalVariableBase + VariableOffset);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit d9efd68

Please sign in to comment.