1 /*++ 2 3 Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR> 4 This program and the accompanying materials 5 are licensed and made available under the terms and conditions of the BSD License 6 which accompanies this distribution. The full text of the license may be found at 7 http://opensource.org/licenses/bsd-license.php 8 9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 12 Module Name: 13 14 RtPlatformStatusCode.c 15 16 Abstract: 17 18 Contains NT32 specific implementations required to use status codes. 19 20 --*/ 21 22 // 23 // Statements that include other files. 24 // 25 #include "Tiano.h" 26 #include "EfiCommonLib.h" 27 #include "EfiRuntimeLib.h" 28 #include "EfiStatusCode.h" 29 #include "EfiHobLib.h" 30 #include "RtMemoryStatusCodeLib.h" 31 #include "BsDataHubStatusCodeLib.h" 32 33 // 34 // Consumed protocols 35 // 36 #include EFI_ARCH_PROTOCOL_CONSUMER (StatusCode) 37 38 // 39 // GUID definitions 40 // 41 #include EFI_GUID_DEFINITION (Hob) 42 43 // 44 // Globals only work at BootService Time. NOT at Runtime! 45 // 46 EFI_REPORT_STATUS_CODE mPeiReportStatusCode; 47 48 // 49 // Function implementations 50 // 51 EFI_STATUS 52 EFIAPI 53 RtPlatformReportStatusCode ( 54 IN EFI_STATUS_CODE_TYPE CodeType, 55 IN EFI_STATUS_CODE_VALUE Value, 56 IN UINT32 Instance, 57 IN EFI_GUID * CallerId, 58 IN EFI_STATUS_CODE_DATA * Data OPTIONAL 59 ) 60 /*++ 61 62 Routine Description: 63 64 Call all status code listeners in the MonoStatusCode. 65 66 Arguments: 67 68 Same as ReportStatusCode service 69 70 Returns: 71 72 EFI_SUCCESS Always returns success. 73 74 --*/ 75 { 76 RtMemoryReportStatusCode (CodeType, Value, Instance, CallerId, Data); 77 if (EfiAtRuntime ()) { 78 // 79 // For now all we do is post code at runtime 80 // 81 return EFI_SUCCESS; 82 } 83 84 BsDataHubReportStatusCode (CodeType, Value, Instance, CallerId, Data); 85 86 // 87 // Call back into PEI to get status codes. This is because SecMain contains 88 // status code that reports to Win32. 89 // 90 if (mPeiReportStatusCode != NULL) { 91 return mPeiReportStatusCode (CodeType, Value, Instance, CallerId, Data); 92 } 93 94 return EFI_SUCCESS; 95 } 96 97 VOID 98 EFIAPI 99 RtPlatformInitializeStatusCode ( 100 IN EFI_HANDLE ImageHandle, 101 IN EFI_SYSTEM_TABLE *SystemTable 102 ) 103 /*++ 104 105 Routine Description: 106 107 Initialize the status code listeners. 108 109 Arguments: 110 111 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT) 112 113 Returns: 114 115 None 116 117 --*/ 118 { 119 EFI_STATUS Status; 120 VOID *HobList; 121 VOID *Pointer; 122 123 RtMemoryInitializeStatusCode (ImageHandle, SystemTable); 124 BsDataHubInitializeStatusCode (ImageHandle, SystemTable); 125 126 // 127 // Play any prior status codes to the data hub. 128 // 129 PlaybackStatusCodes (BsDataHubReportStatusCode); 130 131 // 132 // If PEI has a ReportStatusCode callback find it and use it before StdErr 133 // is connected. 134 // 135 mPeiReportStatusCode = NULL; 136 Pointer = NULL; 137 Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList); 138 if (!EFI_ERROR (Status)) { 139 Status = GetNextGuidHob (&HobList, &gEfiStatusCodeRuntimeProtocolGuid, &Pointer, NULL); 140 if (!EFI_ERROR (Status) && (Pointer != NULL)) { 141 mPeiReportStatusCode = (EFI_REPORT_STATUS_CODE) (*(UINTN *) Pointer); 142 } 143 } 144 } 145