]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/StatusCodeHandler/Smm/SerialStatusCodeWorker.c
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Universal / StatusCodeHandler / Smm / SerialStatusCodeWorker.c
1 /** @file
2 Serial I/O status code reporting worker.
3
4 Copyright (c) 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
15 #include "StatusCodeHandlerSmm.h"
16
17 /**
18 Convert status code value and extended data to readable ASCII string, send string to serial I/O device.
19
20 @param CodeType Indicates the type of status code being reported.
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
23 classify the entity as well as an operation.
24 @param Instance The enumeration of a hardware or software entity within
25 the system. Valid instance numbers start with 1.
26 @param CallerId This optional parameter may be used to identify the caller.
27 This parameter allows the status code driver to apply different rules to
28 different callers.
29 @param Data This optional parameter may be used to pass additional data.
30
31 @retval EFI_SUCCESS Status code reported to serial I/O successfully.
32 @retval EFI_DEVICE_ERROR EFI serial device cannot work after ExitBootService() is called.
33 @retval EFI_DEVICE_ERROR EFI serial device cannot work with TPL higher than TPL_CALLBACK.
34
35 **/
36 EFI_STATUS
37 EFIAPI
38 SerialStatusCodeReportWorker (
39 IN EFI_STATUS_CODE_TYPE CodeType,
40 IN EFI_STATUS_CODE_VALUE Value,
41 IN UINT32 Instance,
42 IN EFI_GUID *CallerId,
43 IN EFI_STATUS_CODE_DATA *Data OPTIONAL
44 )
45 {
46 CHAR8 *Filename;
47 CHAR8 *Description;
48 CHAR8 *Format;
49 CHAR8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
50 UINT32 ErrorLevel;
51 UINT32 LineNumber;
52 UINTN CharCount;
53 BASE_LIST Marker;
54
55 Buffer[0] = '\0';
56
57 if (Data != NULL &&
58 ReportStatusCodeExtractAssertInfo (CodeType, Value, Data, &Filename, &Description, &LineNumber)) {
59 //
60 // Print ASSERT() information into output buffer.
61 //
62 CharCount = AsciiSPrint (
63 Buffer,
64 sizeof (Buffer),
65 "\n\rDXE_ASSERT!: %a (%d): %a\n\r",
66 Filename,
67 LineNumber,
68 Description
69 );
70 } else if (Data != NULL &&
71 ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
72 //
73 // Print DEBUG() information into output buffer.
74 //
75 CharCount = AsciiBSPrint (
76 Buffer,
77 sizeof (Buffer),
78 Format,
79 Marker
80 );
81 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
82 //
83 // Print ERROR information into output buffer.
84 //
85 CharCount = AsciiSPrint (
86 Buffer,
87 sizeof (Buffer),
88 "ERROR: C%x:V%x I%x",
89 CodeType,
90 Value,
91 Instance
92 );
93
94 if (CallerId != NULL) {
95 CharCount += AsciiSPrint (
96 &Buffer[CharCount - 1],
97 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
98 " %g",
99 CallerId
100 );
101 }
102
103 if (Data != NULL) {
104 CharCount += AsciiSPrint (
105 &Buffer[CharCount - 1],
106 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
107 " %x",
108 Data
109 );
110 }
111
112 CharCount += AsciiSPrint (
113 &Buffer[CharCount - 1],
114 (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),
115 "\n\r"
116 );
117 } else if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
118 //
119 // Print PROGRESS information into output buffer.
120 //
121 CharCount = AsciiSPrint (
122 Buffer,
123 sizeof (Buffer),
124 "PROGRESS CODE: V%x I%x\n\r",
125 Value,
126 Instance
127 );
128 } else {
129 //
130 // Code type is not defined.
131 //
132 CharCount = AsciiSPrint (
133 Buffer,
134 sizeof (Buffer),
135 "Undefined: C%x:V%x I%x\n\r",
136 CodeType,
137 Value,
138 Instance
139 );
140 }
141
142 //
143 // Call SerialPort Lib function to do print.
144 //
145 SerialPortWrite ((UINT8 *) Buffer, CharCount);
146
147 return EFI_SUCCESS;
148 }
149