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