utexcep.c revision 1.1.1.1.10.3 1 1.1.1.1.10.2 tls /*******************************************************************************
2 1.1.1.1.10.2 tls *
3 1.1.1.1.10.2 tls * Module Name: utexcep - Exception code support
4 1.1.1.1.10.2 tls *
5 1.1.1.1.10.2 tls ******************************************************************************/
6 1.1.1.1.10.2 tls
7 1.1.1.1.10.2 tls /*
8 1.1.1.1.10.3 jdolecek * Copyright (C) 2000 - 2017, Intel Corp.
9 1.1.1.1.10.2 tls * All rights reserved.
10 1.1.1.1.10.2 tls *
11 1.1.1.1.10.2 tls * Redistribution and use in source and binary forms, with or without
12 1.1.1.1.10.2 tls * modification, are permitted provided that the following conditions
13 1.1.1.1.10.2 tls * are met:
14 1.1.1.1.10.2 tls * 1. Redistributions of source code must retain the above copyright
15 1.1.1.1.10.2 tls * notice, this list of conditions, and the following disclaimer,
16 1.1.1.1.10.2 tls * without modification.
17 1.1.1.1.10.2 tls * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.1.10.2 tls * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.1.10.2 tls * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.1.10.2 tls * including a substantially similar Disclaimer requirement for further
21 1.1.1.1.10.2 tls * binary redistribution.
22 1.1.1.1.10.2 tls * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.1.10.2 tls * of any contributors may be used to endorse or promote products derived
24 1.1.1.1.10.2 tls * from this software without specific prior written permission.
25 1.1.1.1.10.2 tls *
26 1.1.1.1.10.2 tls * Alternatively, this software may be distributed under the terms of the
27 1.1.1.1.10.2 tls * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.1.10.2 tls * Software Foundation.
29 1.1.1.1.10.2 tls *
30 1.1.1.1.10.2 tls * NO WARRANTY
31 1.1.1.1.10.2 tls * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.1.10.2 tls * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.1.10.2 tls * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.1.10.2 tls * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.1.10.2 tls * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.1.10.2 tls * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.1.10.2 tls * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.1.10.2 tls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.1.10.2 tls * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.1.10.2 tls * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.1.10.2 tls * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.1.10.2 tls */
43 1.1.1.1.10.2 tls
44 1.1.1.1.10.2 tls #define EXPORT_ACPI_INTERFACES
45 1.1.1.1.10.2 tls
46 1.1.1.1.10.2 tls #define ACPI_DEFINE_EXCEPTION_TABLE
47 1.1.1.1.10.2 tls #include "acpi.h"
48 1.1.1.1.10.2 tls #include "accommon.h"
49 1.1.1.1.10.2 tls
50 1.1.1.1.10.2 tls
51 1.1.1.1.10.2 tls #define _COMPONENT ACPI_UTILITIES
52 1.1.1.1.10.2 tls ACPI_MODULE_NAME ("utexcep")
53 1.1.1.1.10.2 tls
54 1.1.1.1.10.2 tls
55 1.1.1.1.10.2 tls /*******************************************************************************
56 1.1.1.1.10.2 tls *
57 1.1.1.1.10.2 tls * FUNCTION: AcpiFormatException
58 1.1.1.1.10.2 tls *
59 1.1.1.1.10.2 tls * PARAMETERS: Status - The ACPI_STATUS code to be formatted
60 1.1.1.1.10.2 tls *
61 1.1.1.1.10.2 tls * RETURN: A string containing the exception text. A valid pointer is
62 1.1.1.1.10.2 tls * always returned.
63 1.1.1.1.10.2 tls *
64 1.1.1.1.10.2 tls * DESCRIPTION: This function translates an ACPI exception into an ASCII
65 1.1.1.1.10.2 tls * string. Returns "unknown status" string for invalid codes.
66 1.1.1.1.10.2 tls *
67 1.1.1.1.10.2 tls ******************************************************************************/
68 1.1.1.1.10.2 tls
69 1.1.1.1.10.2 tls const char *
70 1.1.1.1.10.2 tls AcpiFormatException (
71 1.1.1.1.10.2 tls ACPI_STATUS Status)
72 1.1.1.1.10.2 tls {
73 1.1.1.1.10.2 tls const ACPI_EXCEPTION_INFO *Exception;
74 1.1.1.1.10.2 tls
75 1.1.1.1.10.2 tls
76 1.1.1.1.10.2 tls ACPI_FUNCTION_ENTRY ();
77 1.1.1.1.10.2 tls
78 1.1.1.1.10.2 tls
79 1.1.1.1.10.2 tls Exception = AcpiUtValidateException (Status);
80 1.1.1.1.10.2 tls if (!Exception)
81 1.1.1.1.10.2 tls {
82 1.1.1.1.10.2 tls /* Exception code was not recognized */
83 1.1.1.1.10.2 tls
84 1.1.1.1.10.2 tls ACPI_ERROR ((AE_INFO,
85 1.1.1.1.10.2 tls "Unknown exception code: 0x%8.8X", Status));
86 1.1.1.1.10.2 tls
87 1.1.1.1.10.2 tls return ("UNKNOWN_STATUS_CODE");
88 1.1.1.1.10.2 tls }
89 1.1.1.1.10.2 tls
90 1.1.1.1.10.2 tls return (Exception->Name);
91 1.1.1.1.10.2 tls }
92 1.1.1.1.10.2 tls
93 1.1.1.1.10.2 tls ACPI_EXPORT_SYMBOL (AcpiFormatException)
94 1.1.1.1.10.2 tls
95 1.1.1.1.10.2 tls
96 1.1.1.1.10.2 tls /*******************************************************************************
97 1.1.1.1.10.2 tls *
98 1.1.1.1.10.2 tls * FUNCTION: AcpiUtValidateException
99 1.1.1.1.10.2 tls *
100 1.1.1.1.10.2 tls * PARAMETERS: Status - The ACPI_STATUS code to be formatted
101 1.1.1.1.10.2 tls *
102 1.1.1.1.10.2 tls * RETURN: A string containing the exception text. NULL if exception is
103 1.1.1.1.10.2 tls * not valid.
104 1.1.1.1.10.2 tls *
105 1.1.1.1.10.2 tls * DESCRIPTION: This function validates and translates an ACPI exception into
106 1.1.1.1.10.2 tls * an ASCII string.
107 1.1.1.1.10.2 tls *
108 1.1.1.1.10.2 tls ******************************************************************************/
109 1.1.1.1.10.2 tls
110 1.1.1.1.10.2 tls const ACPI_EXCEPTION_INFO *
111 1.1.1.1.10.2 tls AcpiUtValidateException (
112 1.1.1.1.10.2 tls ACPI_STATUS Status)
113 1.1.1.1.10.2 tls {
114 1.1.1.1.10.2 tls UINT32 SubStatus;
115 1.1.1.1.10.2 tls const ACPI_EXCEPTION_INFO *Exception = NULL;
116 1.1.1.1.10.2 tls
117 1.1.1.1.10.2 tls
118 1.1.1.1.10.2 tls ACPI_FUNCTION_ENTRY ();
119 1.1.1.1.10.2 tls
120 1.1.1.1.10.2 tls
121 1.1.1.1.10.2 tls /*
122 1.1.1.1.10.2 tls * Status is composed of two parts, a "type" and an actual code
123 1.1.1.1.10.2 tls */
124 1.1.1.1.10.2 tls SubStatus = (Status & ~AE_CODE_MASK);
125 1.1.1.1.10.2 tls
126 1.1.1.1.10.2 tls switch (Status & AE_CODE_MASK)
127 1.1.1.1.10.2 tls {
128 1.1.1.1.10.2 tls case AE_CODE_ENVIRONMENTAL:
129 1.1.1.1.10.2 tls
130 1.1.1.1.10.2 tls if (SubStatus <= AE_CODE_ENV_MAX)
131 1.1.1.1.10.2 tls {
132 1.1.1.1.10.2 tls Exception = &AcpiGbl_ExceptionNames_Env [SubStatus];
133 1.1.1.1.10.2 tls }
134 1.1.1.1.10.2 tls break;
135 1.1.1.1.10.2 tls
136 1.1.1.1.10.2 tls case AE_CODE_PROGRAMMER:
137 1.1.1.1.10.2 tls
138 1.1.1.1.10.2 tls if (SubStatus <= AE_CODE_PGM_MAX)
139 1.1.1.1.10.2 tls {
140 1.1.1.1.10.2 tls Exception = &AcpiGbl_ExceptionNames_Pgm [SubStatus];
141 1.1.1.1.10.2 tls }
142 1.1.1.1.10.2 tls break;
143 1.1.1.1.10.2 tls
144 1.1.1.1.10.2 tls case AE_CODE_ACPI_TABLES:
145 1.1.1.1.10.2 tls
146 1.1.1.1.10.2 tls if (SubStatus <= AE_CODE_TBL_MAX)
147 1.1.1.1.10.2 tls {
148 1.1.1.1.10.2 tls Exception = &AcpiGbl_ExceptionNames_Tbl [SubStatus];
149 1.1.1.1.10.2 tls }
150 1.1.1.1.10.2 tls break;
151 1.1.1.1.10.2 tls
152 1.1.1.1.10.2 tls case AE_CODE_AML:
153 1.1.1.1.10.2 tls
154 1.1.1.1.10.2 tls if (SubStatus <= AE_CODE_AML_MAX)
155 1.1.1.1.10.2 tls {
156 1.1.1.1.10.2 tls Exception = &AcpiGbl_ExceptionNames_Aml [SubStatus];
157 1.1.1.1.10.2 tls }
158 1.1.1.1.10.2 tls break;
159 1.1.1.1.10.2 tls
160 1.1.1.1.10.2 tls case AE_CODE_CONTROL:
161 1.1.1.1.10.2 tls
162 1.1.1.1.10.2 tls if (SubStatus <= AE_CODE_CTRL_MAX)
163 1.1.1.1.10.2 tls {
164 1.1.1.1.10.2 tls Exception = &AcpiGbl_ExceptionNames_Ctrl [SubStatus];
165 1.1.1.1.10.2 tls }
166 1.1.1.1.10.2 tls break;
167 1.1.1.1.10.2 tls
168 1.1.1.1.10.2 tls default:
169 1.1.1.1.10.2 tls
170 1.1.1.1.10.2 tls break;
171 1.1.1.1.10.2 tls }
172 1.1.1.1.10.2 tls
173 1.1.1.1.10.2 tls if (!Exception || !Exception->Name)
174 1.1.1.1.10.2 tls {
175 1.1.1.1.10.2 tls return (NULL);
176 1.1.1.1.10.2 tls }
177 1.1.1.1.10.2 tls
178 1.1.1.1.10.2 tls return (Exception);
179 1.1.1.1.10.2 tls }
180