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