]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/StatusCodeHandler/Pei/SerialStatusCodeWorker.c
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Universal / StatusCodeHandler / Pei / SerialStatusCodeWorker.c
1 /** @file
2 Serial I/O status code reporting worker.
3
4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
5 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 "StatusCodeHandlerPei.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 PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
20 @param CodeType Indicates the type of status code being reported.
21 @param Value Describes the current status of a hardware or
22 software entity. This includes information about the class and
23 subclass that is used to classify the entity as well as an operation.
24 For progress codes, the operation is the current activity.
25 For error codes, it is the exception.For debug codes,it is not defined at this time.
26 @param Instance The enumeration of a hardware or software entity within
27 the system. A system may contain multiple entities that match a class/subclass
28 pairing. The instance differentiates between them. An instance of 0 indicates
29 that instance information is unavailable, not meaningful, or not relevant.
30 Valid instance numbers start with 1.
31 @param CallerId This optional parameter may be used to identify the caller.
32 This parameter allows the status code driver to apply different rules to
33 different callers.
34 @param Data This optional parameter may be used to pass additional data.
35
36 @retval EFI_SUCCESS Status code reported to serial I/O successfully.
37
38 **/
39 EFI_STATUS
40 SerialStatusCodeReportWorker (
41 IN CONST EFI_PEI_SERVICES **PeiServices,
42 IN EFI_STATUS_CODE_TYPE CodeType,
43 IN EFI_STATUS_CODE_VALUE Value,
44 IN UINT32 Instance,
45 IN CONST EFI_GUID *CallerId,
46 IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
47 )
48 {
49 CHAR8 *Filename;
50 CHAR8 *Description;
51 CHAR8 *Format;
52 CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
53 UINT32 ErrorLevel;
54 UINT32 LineNumber;
55 UINTN CharCount;
56 BASE_LIST Marker;
57
58 Buffer[0] = '\0';
59
60 if (Data != NULL &&
61 ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
62 //
63 // Print ASSERT() information into output buffer.
64 //
65 CharCount = AsciiSPrint (
66 Buffer,
67 sizeof (Buffer),
68 "\n\rPEI_ASSERT!: %a (%d): %a\n\r",
69 Filename,
70 LineNumber,
71 Description
72 );
73 } else if (Data != NULL &&
74 ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
75 //
76 // Print DEBUG() information into output buffer.
77 //
78 CharCount = AsciiBSPrint (
79 Buffer,
80 sizeof (Buffer),
81 Format,
82 Marker
83 );
84 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
85 //
86 // Print ERROR information into output buffer.
87 //
88 CharCount = AsciiSPrint (
89 Buffer,
90 sizeof (Buffer),
91 "ERROR: C%x:V%x I%x",
92 CodeType,
93 Value,
94 Instance
95 );
96
97 if (CallerId != NULL) {
98 CharCount += AsciiSPrint (
99 &Buffer[CharCount - 1],
100 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
101 " %g",
102 CallerId
103 );
104 }
105
106 if (Data != NULL) {
107 CharCount += AsciiSPrint (
108 &Buffer[CharCount - 1],
109 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
110 " %x",
111 Data
112 );
113 }
114
115 CharCount += AsciiSPrint (
116 &Buffer[CharCount - 1],
117 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
118 "\n\r"
119 );
120 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
121 //
122 // Print PROGRESS information into output buffer.
123 //
124 CharCount = AsciiSPrint (
125 Buffer,
126 sizeof (Buffer),
127 "PROGRESS CODE: V%x I%x\n\r",
128 Value,
129 Instance
130 );
131 } else {
132 //
133 // Code type is not defined.
134 //
135 CharCount = AsciiSPrint (
136 Buffer,
137 sizeof (Buffer),
138 "Undefined: C%x:V%x I%x\n\r",
139 CodeType,
140 Value,
141 Instance
142 );
143 }
144
145 //
146 // Call SerialPort Lib function to do print.
147 //
148 SerialPortWrite ((UINT8 *) Buffer, CharCount);
149
150 return EFI_SUCCESS;
151 }
152