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