X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ArmPkg%2FInclude%2FAsmMacroIoLib.h;h=408b2ca28074fb46803ed9b53802297dc768164f;hp=aa3ed61632f1a6ca2758bea99cc2ce263fadaa3a;hb=3402aac7d985bf8a9f9d3c639f3fe93609380513;hpb=2ef2b01e07c02db339f34004445734a2dbdd80e1 diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h index aa3ed61632..408b2ca280 100644 --- a/ArmPkg/Include/AsmMacroIoLib.h +++ b/ArmPkg/Include/AsmMacroIoLib.h @@ -1,9 +1,10 @@ /** @file Macros to work around lack of Apple support for LDR register, =expr - Copyright (c) 2008-2009 Apple Inc. All rights reserved.
+ Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+ Copyright (c) 2011-2012, ARM Ltd. All rights reserved.
- All rights reserved. This program and the accompanying materials + 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 @@ -119,6 +120,38 @@ .long (_Data) ; \ 1: +// Reserve a region at the top of the Primary Core stack +// for Global variables for the XIP phase +#define SetPrimaryStack(StackTop, GlobalSize, Tmp) \ + and Tmp, GlobalSize, #7 ; \ + rsbne Tmp, Tmp, #8 ; \ + add GlobalSize, GlobalSize, Tmp ; \ + sub sp, StackTop, GlobalSize ; \ + ; \ + mov Tmp, sp ; \ + mov GlobalSize, #0x0 ; \ +_SetPrimaryStackInitGlobals: ; \ + cmp Tmp, StackTop ; \ + beq _SetPrimaryStackEnd ; \ + str GlobalSize, [Tmp], #4 ; \ + b _SetPrimaryStackInitGlobals ; \ +_SetPrimaryStackEnd: + +// Initialize the Global Variable with '0' +#define InitializePrimaryStack(GlobalSize, Tmp1) \ + and Tmp1, GlobalSize, #7 ; \ + rsbne Tmp1, Tmp1, #8 ; \ + add GlobalSize, GlobalSize, Tmp1 ; \ + ; \ + mov Tmp1, sp ; \ + sub sp, GlobalSize ; \ + mov GlobalSize, #0x0 ; \ +_InitializePrimaryStackLoop: ; \ + cmp Tmp1, sp ; \ + bls _InitializePrimaryStackEnd ; \ + str GlobalSize, [Tmp1], #-4 ; \ + b _InitializePrimaryStackLoop ; \ +_InitializePrimaryStackEnd: #elif defined (__GNUC__) @@ -126,7 +159,7 @@ ldr r1, =Address ; \ ldr r0, =Data ; \ str r0, [r1] - + #define MmioOr32(Address, OrData) \ ldr r1, =Address ; \ ldr r2, =OrData ; \ @@ -148,7 +181,7 @@ and r0, r0, r2 ; \ ldr r2, =OrData ; \ orr r0, r0, r2 ; \ - str r0, [r1] + str r0, [r1] #define MmioWriteFromReg32(Address, Reg) \ ldr r1, =Address ; \ @@ -167,11 +200,42 @@ #define LoadConstantToReg(Data, Reg) \ ldr Reg, =Data - + +#define SetPrimaryStack(StackTop, GlobalSize, Tmp) \ + and Tmp, GlobalSize, #7 ; \ + rsbne Tmp, Tmp, #8 ; \ + add GlobalSize, GlobalSize, Tmp ; \ + sub sp, StackTop, GlobalSize ; \ + ; \ + mov Tmp, sp ; \ + mov GlobalSize, #0x0 ; \ +_SetPrimaryStackInitGlobals: ; \ + cmp Tmp, StackTop ; \ + beq _SetPrimaryStackEnd ; \ + str GlobalSize, [Tmp], #4 ; \ + b _SetPrimaryStackInitGlobals ; \ +_SetPrimaryStackEnd: + +// Initialize the Global Variable with '0' +#define InitializePrimaryStack(GlobalSize, Tmp1) \ + and Tmp1, GlobalSize, #7 ; \ + rsbne Tmp1, Tmp1, #8 ; \ + add GlobalSize, GlobalSize, Tmp1 ; \ + ; \ + mov Tmp1, sp ; \ + sub sp, GlobalSize ; \ + mov GlobalSize, #0x0 ; \ +_InitializePrimaryStackLoop: ; \ + cmp Tmp1, sp ; \ + bls _InitializePrimaryStackEnd ; \ + str GlobalSize, [Tmp1], #-4 ; \ + b _InitializePrimaryStackLoop ; \ +_InitializePrimaryStackEnd: + #else // -// Use ARM assembly macros, form armasam +// Use ARM assembly macros, form armasam // // Less magic in the macros if ldr reg, =expr works // @@ -187,7 +251,7 @@ // returns Data in R0 and Address in R1, and OrData in r2 #define MmioOr32(Address, OrData) MmioOr32Macro Address, OrData - + // returns _Data in R0 and _Address in R1, and _OrData in r2 @@ -229,8 +293,11 @@ // conditional load testing eq flag #define LoadConstantToRegIfEq(Data, Reg) LoadConstantToRegIfEqMacro Data, Reg +#define SetPrimaryStack(StackTop,GlobalSize,Tmp) SetPrimaryStack StackTop, GlobalSize, Tmp -#endif +// Initialize the Global Variable with '0' +#define InitializePrimaryStack(GlobalSize, Tmp1) InitializePrimaryStack GlobalSize, Tmp1 +#endif #endif