]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Universal/StatusCode/Pei/SerialStatusCodeWorker.c
Enhance PciCfg2 driver to handle unaligned Pci access according to PI spec.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / StatusCode / Pei / SerialStatusCodeWorker.c
1 /** @file
2 Serial I/O status code reporting worker.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 **/
13
14 #include "PeiStatusCode.h"
15
16 /**
17 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
18
19 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
20
21 @param Value Describes the current status of a hardware or software entity.
22 This included information about the class and subclass that is used to classify the entity
23 as well as an operation. For progress codes, the operation is the current activity.
24 For error codes, it is the exception. For debug codes, it is not defined at this time.
25 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
26 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
27
28 @param Instance The enumeration of a hardware or software entity within the system.
29 A system may contain multiple entities that match a class/subclass pairing.
30 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
31 not meaningful, or not relevant. Valid instance numbers start with 1.
32
33
34 @param CallerId This optional parameter may be used to identify the caller.
35 This parameter allows the status code driver to apply different rules to different callers.
36 Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.
37
38
39 @param Data This optional parameter may be used to pass additional data
40
41 @return The function always return EFI_SUCCESS.
42
43 **/
44 EFI_STATUS
45 SerialStatusCodeReportWorker (
46 IN EFI_STATUS_CODE_TYPE CodeType,
47 IN EFI_STATUS_CODE_VALUE Value,
48 IN UINT32 Instance,
49 IN CONST EFI_GUID *CallerId,
50 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
51 )
52 {
53 CHAR8 *Filename;
54 CHAR8 *Description;
55 CHAR8 *Format;
56 CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
57 UINT32 ErrorLevel;
58 UINT32 LineNumber;
59 UINTN CharCount;
60 VA_LIST Marker;
61
62 Buffer[0] = '\0';
63
64 if (Data != NULL &&
65 ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
66 //
67 // Print ASSERT() information into output buffer.
68 //
69 CharCount = AsciiSPrint (
70 Buffer,
71 EFI_STATUS_CODE_DATA_MAX_SIZE,
72 "\n\rPEI_ASSERT!: %a (%d): %a\n\r",
73 Filename,
74 LineNumber,
75 Description
76 );
77 } else if (Data != NULL &&
78 ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
79 //
80 // Print DEBUG() information into output buffer.
81 //
82 CharCount = AsciiVSPrint (
83 Buffer,
84 EFI_STATUS_CODE_DATA_MAX_SIZE,
85 Format,
86 Marker
87 );
88 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
89 //
90 // Print ERROR information into output buffer.
91 //
92 CharCount = AsciiSPrint (
93 Buffer,
94 EFI_STATUS_CODE_DATA_MAX_SIZE,
95 "ERROR: C%x:V%x I%x",
96 CodeType,
97 Value,
98 Instance
99 );
100
101 //
102 // Make sure we don't try to print values that weren't intended to be printed, especially NULL GUID pointers.
103 //
104
105 if (CallerId != NULL) {
106 CharCount += AsciiSPrint (
107 &Buffer[CharCount - 1],
108 (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
109 " %g",
110 CallerId
111 );
112 }
113
114 if (Data != NULL) {
115 CharCount += AsciiSPrint (
116 &Buffer[CharCount - 1],
117 (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
118 " %x",
119 Data
120 );
121 }
122
123 CharCount += AsciiSPrint (
124 &Buffer[CharCount - 1],
125 (EFI_STATUS_CODE_DATA_MAX_SIZE - (sizeof (Buffer[0]) * CharCount)),
126 "\n\r"
127 );
128 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
129 CharCount = AsciiSPrint (
130 Buffer,
131 EFI_STATUS_CODE_DATA_MAX_SIZE,
132 "PROGRESS CODE: V%x I%x\n\r",
133 Value,
134 Instance
135 );
136 } else {
137 CharCount = AsciiSPrint (
138 Buffer,
139 EFI_STATUS_CODE_DATA_MAX_SIZE,
140 "Undefined: C%x:V%x I%x\n\r",
141 CodeType,
142 Value,
143 Instance
144 );
145 }
146
147 //
148 // Callout to SerialPort Lib function to do print.
149 //
150 SerialPortWrite ((UINT8 *) Buffer, CharCount);
151
152 return EFI_SUCCESS;
153 }
154