From b4e53e389d2a04678fb28bc445cd5b554bb175e0 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Mon, 4 Aug 2014 14:18:13 +0000 Subject: ArmPkg/ArmSmcLib: Fixed SMC helper functions The SMC helper functions were buggy as they were assuming that the values in x1-x7 registers were preserved across an SMC call, which is not the case. This patch fixes this issue. It also simplifies the code by providing only 1 version of the SMC helper function. We used to have 4 versions depending on the number of arguments. The problem with this approach was that the number of arguments also dictated the number of return values, which is completely unrelated. E.g. you can have an SMC call that takes 1 argument but returns 4 values. 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@15748 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPkg/Include/Library/ArmSmcLib.h | 44 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'ArmPkg/Include') diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/ArmSmcLib.h index ff946f2dea..168e3bb426 100644 --- a/ArmPkg/Include/Library/ArmSmcLib.h +++ b/ArmPkg/Include/Library/ArmSmcLib.h @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2012, ARM Limited. All rights reserved. +* Copyright (c) 2012-2014, 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 @@ -15,30 +15,32 @@ #ifndef __ARM_SMC_LIB__ #define __ARM_SMC_LIB__ -VOID -ArmCallSmc ( - IN OUT UINTN *Rx - ); +/** + * The size of the SMC arguments are different between AArch64 and AArch32. + * The native size is used for the arguments. + */ +typedef struct { + UINTN Arg0; + UINTN Arg1; + UINTN Arg2; + UINTN Arg3; + UINTN Arg4; + UINTN Arg5; + UINTN Arg6; + UINTN Arg7; +} ARM_SMC_ARGS; -VOID -ArmCallSmcArg1 ( - IN OUT UINTN *Rx, - IN OUT UINTN *Arg1 - ); +/** + Trigger an SMC call -VOID -ArmCallSmcArg2 ( - IN OUT UINTN *Rx, - IN OUT UINTN *Arg1, - IN OUT UINTN *Arg2 - ); + SMC calls can take up to 7 arguments and return up to 4 return values. + Therefore, the 4 first fields in the ARM_SMC_ARGS structure are used + for both input and output values. +**/ VOID -ArmCallSmcArg3 ( - IN OUT UINTN *Rx, - IN OUT UINTN *Arg1, - IN OUT UINTN *Arg2, - IN OUT UINTN *Arg3 +ArmCallSmc ( + IN OUT ARM_SMC_ARGS *Args ); #endif -- cgit v1.2.3