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