]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/PeiDebugPrintHobLib/PeiDebugPrintHobLib.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Library / PeiDebugPrintHobLib / PeiDebugPrintHobLib.c
CommitLineData
d4a78455 1/** @file\r
2 NULL Library class that reads Debug Mask variable and if it exists makes a\r
3 HOB that contains the debug mask.\r
4\r
5 Copyright (c) 2011, Apple, Inc. All rights reserved.<BR>\r
9d510e61 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
d4a78455 7\r
8**/\r
9\r
10#include <PiPei.h>\r
11\r
12#include <Library/HobLib.h>\r
13#include <Library/DebugLib.h>\r
14#include <Library/PeiServicesLib.h>\r
15\r
16#include <Ppi/ReadOnlyVariable2.h>\r
17#include <Guid/DebugMask.h>\r
18\r
19\r
20/**\r
21 The constructor reads variable and sets HOB\r
d1102dba 22\r
d4a78455 23 @param FileHandle The handle of FFS header the loaded driver.\r
24 @param PeiServices The pointer to the PEI services.\r
25\r
26 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
27\r
28**/\r
29EFI_STATUS\r
30EFIAPI\r
31PeiDebugPrintHobLibConstructor (\r
32 IN EFI_PEI_FILE_HANDLE FileHandle,\r
33 IN CONST EFI_PEI_SERVICES **PeiServices\r
34 )\r
35{\r
36 EFI_STATUS Status;\r
37 EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;\r
38 UINTN Size;\r
39 UINT64 GlobalErrorLevel;\r
40 UINT32 HobErrorLevel;\r
d1102dba 41\r
d4a78455 42 Status = PeiServicesLocatePpi (\r
43 &gEfiPeiReadOnlyVariable2PpiGuid,\r
44 0,\r
45 NULL,\r
46 (VOID **)&Variable\r
47 );\r
48 if (!EFI_ERROR (Status)) {\r
49 Size = sizeof (GlobalErrorLevel);\r
d1102dba
LG
50 Status = Variable->GetVariable (\r
51 Variable,\r
d4a78455 52 DEBUG_MASK_VARIABLE_NAME,\r
53 &gEfiGenericVariableGuid,\r
54 NULL,\r
55 &Size,\r
56 &GlobalErrorLevel\r
57 );\r
58 if (!EFI_ERROR (Status)) {\r
59 //\r
60 // Build the GUID'ed HOB for DXE\r
61 //\r
62 HobErrorLevel = (UINT32)GlobalErrorLevel;\r
63 BuildGuidDataHob (\r
64 &gEfiGenericVariableGuid,\r
65 &HobErrorLevel,\r
66 sizeof (HobErrorLevel)\r
67 );\r
68 }\r
69 }\r
70\r
71 return EFI_SUCCESS;\r
72}\r