From d5daaa836f46a3f8fe57da37cad7841d2a9c4aca Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Fri, 12 Dec 2014 19:32:50 +0000 Subject: [PATCH] ArmPkg/AsmMacroIoLib: Fixed the global variables initialization The top of the stack always points to 'stack_base + stack_size'. But the stack pointer is decremented before writing to the stack. It means the top byte of the stack is actually 'stack_base + stack_size - 1'. The initialization should also decrement the stack pointer before zero'ing the memory (pre-indexed addressing). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16518 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPkg/Include/AsmMacroIoLib.h | 4 ++-- ArmPkg/Include/AsmMacroIoLib.inc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h index 408b2ca280..6904bdc9b0 100644 --- a/ArmPkg/Include/AsmMacroIoLib.h +++ b/ArmPkg/Include/AsmMacroIoLib.h @@ -149,7 +149,7 @@ _SetPrimaryStackEnd: _InitializePrimaryStackLoop: ; \ cmp Tmp1, sp ; \ bls _InitializePrimaryStackEnd ; \ - str GlobalSize, [Tmp1], #-4 ; \ + str GlobalSize, [Tmp1, #-4]! ; \ b _InitializePrimaryStackLoop ; \ _InitializePrimaryStackEnd: @@ -228,7 +228,7 @@ _SetPrimaryStackEnd: _InitializePrimaryStackLoop: ; \ cmp Tmp1, sp ; \ bls _InitializePrimaryStackEnd ; \ - str GlobalSize, [Tmp1], #-4 ; \ + str GlobalSize, [Tmp1, #-4]! ; \ b _InitializePrimaryStackLoop ; \ _InitializePrimaryStackEnd: diff --git a/ArmPkg/Include/AsmMacroIoLib.inc b/ArmPkg/Include/AsmMacroIoLib.inc index 87e497b31a..301bd890ac 100644 --- a/ArmPkg/Include/AsmMacroIoLib.inc +++ b/ArmPkg/Include/AsmMacroIoLib.inc @@ -113,7 +113,7 @@ _SetPrimaryStackEnd _InitializePrimaryStackLoop cmp $Tmp1, sp bls _InitializePrimaryStackEnd - str $GlobalSize, [$Tmp1], #-4 + str $GlobalSize, [$Tmp1, #-4]! b _InitializePrimaryStackLoop _InitializePrimaryStackEnd MEND