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