]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type32/MiscBootInformationFunction.c
ArmPkg: Allow platforms to report their boot status via OemMiscLib call
[mirror_edk2.git] / ArmPkg / Universal / Smbios / SmbiosMiscDxe / Type32 / MiscBootInformationFunction.c
1 /** @file
2 boot information boot time changes.
3 SMBIOS type 32.
4
5 Based on files under Nt32Pkg/MiscSubClassPlatformDxe/
6
7 Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
8 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
9 Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
10 Copyright (c) 2015, Linaro Limited. All rights reserved.<BR>
11 SPDX-License-Identifier: BSD-2-Clause-Patent
12
13 **/
14
15 #include <Library/BaseLib.h>
16 #include <Library/BaseMemoryLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/MemoryAllocationLib.h>
19 #include <Library/OemMiscLib.h>
20 #include <Library/UefiBootServicesTableLib.h>
21
22 #include "SmbiosMisc.h"
23
24 /**
25 This function makes boot time changes to the contents of the
26 MiscBootInformation (Type 32) record.
27
28 @param RecordData Pointer to SMBIOS table with default values.
29 @param Smbios SMBIOS protocol.
30
31 @retval EFI_SUCCESS The SMBIOS table was successfully added.
32 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
33 @retval EFI_OUT_OF_RESOURCES Failed to allocate required memory.
34
35 **/
36 SMBIOS_MISC_TABLE_FUNCTION(MiscBootInformation)
37 {
38 EFI_STATUS Status;
39 SMBIOS_TABLE_TYPE32 *SmbiosRecord;
40 SMBIOS_TABLE_TYPE32 *InputData;
41
42 //
43 // First check for invalid parameters.
44 //
45 if (RecordData == NULL) {
46 return EFI_INVALID_PARAMETER;
47 }
48
49 InputData = (SMBIOS_TABLE_TYPE32 *)RecordData;
50
51 //
52 // Two zeros following the last string.
53 //
54 SmbiosRecord = AllocateZeroPool (sizeof (SMBIOS_TABLE_TYPE32) + 1 + 1);
55 if (SmbiosRecord == NULL) {
56 return EFI_OUT_OF_RESOURCES;
57 }
58
59 (VOID)CopyMem (SmbiosRecord, InputData, sizeof (SMBIOS_TABLE_TYPE32));
60
61 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE32);
62
63 SmbiosRecord->BootStatus = OemGetBootStatus ();
64
65 //
66 // Now we have got the full smbios record, call smbios protocol to add this record.
67 //
68 Status = SmbiosMiscAddRecord ((UINT8*)SmbiosRecord, NULL);
69 if (EFI_ERROR (Status)) {
70 DEBUG ((DEBUG_ERROR, "[%a]:[%dL] Smbios Type32 Table Log Failed! %r \n",
71 __FUNCTION__, __LINE__, Status));
72 }
73
74 FreePool (SmbiosRecord);
75 return Status;
76 }