Skip to content

Commit

Permalink
AmpereAltraPkg/IpmiBootDxe: Fix failed to set variables
Browse files Browse the repository at this point in the history
Use gEfiGlobalVariableGuid to set the Ampere specific variables cause
invalid parameter issue. This change is to solve this issue by turn to
use gAmpereVariableGuid for these kinds of variable.

Signed-off-by: Vu Nguyen <Vu@amperecomputing.com>
  • Loading branch information
vu-ampere committed Apr 22, 2022
1 parent 6a19505 commit 69a9a68
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
31 changes: 22 additions & 9 deletions Silicon/Ampere/AmpereAltraPkg/Drivers/IpmiBootDxe/IpmiBootDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <Uefi.h>

#include <Guid/AmpereVariable.h>
#include <Guid/GlobalVariable.h>
#include <IndustryStandard/Ipmi.h>
#include <Library/BaseLib.h>
Expand Down Expand Up @@ -385,7 +386,7 @@ HandleIpmiBootOption (
DataSize = sizeof (UINT8);
Status = gRT->GetVariable (
FORCE_UIAPP_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
&gAmpereVariableGuid,
NULL,
&DataSize,
&ForceUiApp
Expand Down Expand Up @@ -435,9 +436,8 @@ HandleIpmiBootOption (
if (!BootFlags.IsPersistent) {
Status = gRT->SetVariable (
EFI_LAST_BOOT_ORDER_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS
| EFI_VARIABLE_NON_VOLATILE,
&gAmpereVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
CurrBootOrderSize,
CurrBootOrder
);
Expand Down Expand Up @@ -502,11 +502,19 @@ HandleIpmiBootOption (
if (UpdateNeed) {
Status = gRT->SetVariable (
FORCE_UIAPP_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
&gAmpereVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
sizeof (UINT8),
&ForceUiApp
);
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"%a: Failed to set the Force UiApp variable - %r\n",
__FUNCTION__,
Status
));
}
}

//
Expand Down Expand Up @@ -567,7 +575,12 @@ RestoreBootOrder (
UINTN CurrBootOrderSize;
UINTN LastBootOrderSize;

GetEfiGlobalVariable2 (EFI_LAST_BOOT_ORDER_VARIABLE_NAME, (VOID **)&LastBootOrder, &LastBootOrderSize);
Status = GetVariable2 (
EFI_LAST_BOOT_ORDER_VARIABLE_NAME,
&gAmpereVariableGuid,
(VOID **)&LastBootOrder,
&LastBootOrderSize
);
if (LastBootOrder == NULL) {
return EFI_SUCCESS;
}
Expand Down Expand Up @@ -596,19 +609,19 @@ RestoreBootOrder (
LastBootOrder
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Failed to restore the BootOrder\n"));
DEBUG ((DEBUG_ERROR, "%a: Failed to restore the BootOrder\n", __FUNCTION__));
goto Exit;
}

Status = gRT->SetVariable (
EFI_LAST_BOOT_ORDER_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
&gAmpereVariableGuid,
0,
0,
NULL
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Failed to erase the LastBootOrder\n"));
DEBUG ((DEBUG_ERROR, "%a: Failed to erase the LastBootOrder\n", __FUNCTION__));
goto Exit;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

[Guids]
gAmpereAfterConsoleEventGuid
gAmpereVariableGuid
gEfiGlobalVariableGuid

[Depex]
Expand Down

0 comments on commit 69a9a68

Please sign in to comment.