1250757Sjkim/*******************************************************************************
2250757Sjkim *
3250757Sjkim * Module Name: uterror - Various internal error/warning output functions
4250757Sjkim *
5250757Sjkim ******************************************************************************/
6250757Sjkim
7250757Sjkim/*
8250757Sjkim * Copyright (C) 2000 - 2013, Intel Corp.
9250757Sjkim * All rights reserved.
10250757Sjkim *
11250757Sjkim * Redistribution and use in source and binary forms, with or without
12250757Sjkim * modification, are permitted provided that the following conditions
13250757Sjkim * are met:
14250757Sjkim * 1. Redistributions of source code must retain the above copyright
15250757Sjkim *    notice, this list of conditions, and the following disclaimer,
16250757Sjkim *    without modification.
17250757Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18250757Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
19250757Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
20250757Sjkim *    including a substantially similar Disclaimer requirement for further
21250757Sjkim *    binary redistribution.
22250757Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
23250757Sjkim *    of any contributors may be used to endorse or promote products derived
24250757Sjkim *    from this software without specific prior written permission.
25250757Sjkim *
26250757Sjkim * Alternatively, this software may be distributed under the terms of the
27250757Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
28250757Sjkim * Software Foundation.
29250757Sjkim *
30250757Sjkim * NO WARRANTY
31250757Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32250757Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33250757Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34250757Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35250757Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36250757Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37250757Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38250757Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39250757Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40250757Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41250757Sjkim * POSSIBILITY OF SUCH DAMAGES.
42250757Sjkim */
43250757Sjkim
44250757Sjkim#define __UTERROR_C__
45250757Sjkim
46250838Sjkim#include <contrib/dev/acpica/include/acpi.h>
47250838Sjkim#include <contrib/dev/acpica/include/accommon.h>
48250838Sjkim#include <contrib/dev/acpica/include/acnamesp.h>
49250757Sjkim
50250757Sjkim
51250757Sjkim#define _COMPONENT          ACPI_UTILITIES
52250757Sjkim        ACPI_MODULE_NAME    ("uterror")
53250757Sjkim
54250757Sjkim
55250757Sjkim/*
56250757Sjkim * This module contains internal error functions that may
57250757Sjkim * be configured out.
58250757Sjkim */
59250757Sjkim#if !defined (ACPI_NO_ERROR_MESSAGES)
60250757Sjkim
61250757Sjkim/*******************************************************************************
62250757Sjkim *
63250757Sjkim * FUNCTION:    AcpiUtPredefinedWarning
64250757Sjkim *
65250757Sjkim * PARAMETERS:  ModuleName      - Caller's module name (for error output)
66250757Sjkim *              LineNumber      - Caller's line number (for error output)
67250757Sjkim *              Pathname        - Full pathname to the node
68250757Sjkim *              NodeFlags       - From Namespace node for the method/object
69250757Sjkim *              Format          - Printf format string + additional args
70250757Sjkim *
71250757Sjkim * RETURN:      None
72250757Sjkim *
73250757Sjkim * DESCRIPTION: Warnings for the predefined validation module. Messages are
74250757Sjkim *              only emitted the first time a problem with a particular
75250757Sjkim *              method/object is detected. This prevents a flood of error
76250757Sjkim *              messages for methods that are repeatedly evaluated.
77250757Sjkim *
78250757Sjkim ******************************************************************************/
79250757Sjkim
80250757Sjkimvoid ACPI_INTERNAL_VAR_XFACE
81250757SjkimAcpiUtPredefinedWarning (
82250757Sjkim    const char              *ModuleName,
83250757Sjkim    UINT32                  LineNumber,
84250757Sjkim    char                    *Pathname,
85250757Sjkim    UINT8                   NodeFlags,
86250757Sjkim    const char              *Format,
87250757Sjkim    ...)
88250757Sjkim{
89250757Sjkim    va_list                 ArgList;
90250757Sjkim
91250757Sjkim
92250757Sjkim    /*
93250757Sjkim     * Warning messages for this method/object will be disabled after the
94250757Sjkim     * first time a validation fails or an object is successfully repaired.
95250757Sjkim     */
96250757Sjkim    if (NodeFlags & ANOBJ_EVALUATED)
97250757Sjkim    {
98250757Sjkim        return;
99250757Sjkim    }
100250757Sjkim
101250757Sjkim    AcpiOsPrintf (ACPI_MSG_WARNING "%s: ", Pathname);
102250757Sjkim
103250757Sjkim    va_start (ArgList, Format);
104250757Sjkim    AcpiOsVprintf (Format, ArgList);
105250757Sjkim    ACPI_MSG_SUFFIX;
106250757Sjkim    va_end (ArgList);
107250757Sjkim}
108250757Sjkim
109250757Sjkim
110250757Sjkim/*******************************************************************************
111250757Sjkim *
112250757Sjkim * FUNCTION:    AcpiUtPredefinedInfo
113250757Sjkim *
114250757Sjkim * PARAMETERS:  ModuleName      - Caller's module name (for error output)
115250757Sjkim *              LineNumber      - Caller's line number (for error output)
116250757Sjkim *              Pathname        - Full pathname to the node
117250757Sjkim *              NodeFlags       - From Namespace node for the method/object
118250757Sjkim *              Format          - Printf format string + additional args
119250757Sjkim *
120250757Sjkim * RETURN:      None
121250757Sjkim *
122250757Sjkim * DESCRIPTION: Info messages for the predefined validation module. Messages
123250757Sjkim *              are only emitted the first time a problem with a particular
124250757Sjkim *              method/object is detected. This prevents a flood of
125250757Sjkim *              messages for methods that are repeatedly evaluated.
126250757Sjkim *
127250757Sjkim ******************************************************************************/
128250757Sjkim
129250757Sjkimvoid ACPI_INTERNAL_VAR_XFACE
130250757SjkimAcpiUtPredefinedInfo (
131250757Sjkim    const char              *ModuleName,
132250757Sjkim    UINT32                  LineNumber,
133250757Sjkim    char                    *Pathname,
134250757Sjkim    UINT8                   NodeFlags,
135250757Sjkim    const char              *Format,
136250757Sjkim    ...)
137250757Sjkim{
138250757Sjkim    va_list                 ArgList;
139250757Sjkim
140250757Sjkim
141250757Sjkim    /*
142250757Sjkim     * Warning messages for this method/object will be disabled after the
143250757Sjkim     * first time a validation fails or an object is successfully repaired.
144250757Sjkim     */
145250757Sjkim    if (NodeFlags & ANOBJ_EVALUATED)
146250757Sjkim    {
147250757Sjkim        return;
148250757Sjkim    }
149250757Sjkim
150250757Sjkim    AcpiOsPrintf (ACPI_MSG_INFO "%s: ", Pathname);
151250757Sjkim
152250757Sjkim    va_start (ArgList, Format);
153250757Sjkim    AcpiOsVprintf (Format, ArgList);
154250757Sjkim    ACPI_MSG_SUFFIX;
155250757Sjkim    va_end (ArgList);
156250757Sjkim}
157250757Sjkim
158250757Sjkim
159250757Sjkim/*******************************************************************************
160250757Sjkim *
161250757Sjkim * FUNCTION:    AcpiUtPredefinedBiosError
162250757Sjkim *
163250757Sjkim * PARAMETERS:  ModuleName      - Caller's module name (for error output)
164250757Sjkim *              LineNumber      - Caller's line number (for error output)
165250757Sjkim *              Pathname        - Full pathname to the node
166250757Sjkim *              NodeFlags       - From Namespace node for the method/object
167250757Sjkim *              Format          - Printf format string + additional args
168250757Sjkim *
169250757Sjkim * RETURN:      None
170250757Sjkim *
171250757Sjkim * DESCRIPTION: BIOS error message for predefined names. Messages
172250757Sjkim *              are only emitted the first time a problem with a particular
173250757Sjkim *              method/object is detected. This prevents a flood of
174250757Sjkim *              messages for methods that are repeatedly evaluated.
175250757Sjkim *
176250757Sjkim ******************************************************************************/
177250757Sjkim
178250757Sjkimvoid ACPI_INTERNAL_VAR_XFACE
179250757SjkimAcpiUtPredefinedBiosError (
180250757Sjkim    const char              *ModuleName,
181250757Sjkim    UINT32                  LineNumber,
182250757Sjkim    char                    *Pathname,
183250757Sjkim    UINT8                   NodeFlags,
184250757Sjkim    const char              *Format,
185250757Sjkim    ...)
186250757Sjkim{
187250757Sjkim    va_list                 ArgList;
188250757Sjkim
189250757Sjkim
190250757Sjkim    /*
191250757Sjkim     * Warning messages for this method/object will be disabled after the
192250757Sjkim     * first time a validation fails or an object is successfully repaired.
193250757Sjkim     */
194250757Sjkim    if (NodeFlags & ANOBJ_EVALUATED)
195250757Sjkim    {
196250757Sjkim        return;
197250757Sjkim    }
198250757Sjkim
199250757Sjkim    AcpiOsPrintf (ACPI_MSG_BIOS_ERROR "%s: ", Pathname);
200250757Sjkim
201250757Sjkim    va_start (ArgList, Format);
202250757Sjkim    AcpiOsVprintf (Format, ArgList);
203250757Sjkim    ACPI_MSG_SUFFIX;
204250757Sjkim    va_end (ArgList);
205250757Sjkim}
206250757Sjkim
207250757Sjkim
208250757Sjkim/*******************************************************************************
209250757Sjkim *
210250757Sjkim * FUNCTION:    AcpiUtNamespaceError
211250757Sjkim *
212250757Sjkim * PARAMETERS:  ModuleName          - Caller's module name (for error output)
213250757Sjkim *              LineNumber          - Caller's line number (for error output)
214250757Sjkim *              InternalName        - Name or path of the namespace node
215250757Sjkim *              LookupStatus        - Exception code from NS lookup
216250757Sjkim *
217250757Sjkim * RETURN:      None
218250757Sjkim *
219250757Sjkim * DESCRIPTION: Print error message with the full pathname for the NS node.
220250757Sjkim *
221250757Sjkim ******************************************************************************/
222250757Sjkim
223250757Sjkimvoid
224250757SjkimAcpiUtNamespaceError (
225250757Sjkim    const char              *ModuleName,
226250757Sjkim    UINT32                  LineNumber,
227250757Sjkim    const char              *InternalName,
228250757Sjkim    ACPI_STATUS             LookupStatus)
229250757Sjkim{
230250757Sjkim    ACPI_STATUS             Status;
231250757Sjkim    UINT32                  BadName;
232250757Sjkim    char                    *Name = NULL;
233250757Sjkim
234250757Sjkim
235250757Sjkim    ACPI_MSG_REDIRECT_BEGIN;
236250757Sjkim    AcpiOsPrintf (ACPI_MSG_ERROR);
237250757Sjkim
238250757Sjkim    if (LookupStatus == AE_BAD_CHARACTER)
239250757Sjkim    {
240250757Sjkim        /* There is a non-ascii character in the name */
241250757Sjkim
242250757Sjkim        ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName));
243250757Sjkim        AcpiOsPrintf ("[0x%.8X] (NON-ASCII)", BadName);
244250757Sjkim    }
245250757Sjkim    else
246250757Sjkim    {
247250757Sjkim        /* Convert path to external format */
248250757Sjkim
249250757Sjkim        Status = AcpiNsExternalizeName (ACPI_UINT32_MAX,
250250757Sjkim                    InternalName, NULL, &Name);
251250757Sjkim
252250757Sjkim        /* Print target name */
253250757Sjkim
254250757Sjkim        if (ACPI_SUCCESS (Status))
255250757Sjkim        {
256250757Sjkim            AcpiOsPrintf ("[%s]", Name);
257250757Sjkim        }
258250757Sjkim        else
259250757Sjkim        {
260250757Sjkim            AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");
261250757Sjkim        }
262250757Sjkim
263250757Sjkim        if (Name)
264250757Sjkim        {
265250757Sjkim            ACPI_FREE (Name);
266250757Sjkim        }
267250757Sjkim    }
268250757Sjkim
269250757Sjkim    AcpiOsPrintf (" Namespace lookup failure, %s",
270250757Sjkim        AcpiFormatException (LookupStatus));
271250757Sjkim
272250757Sjkim    ACPI_MSG_SUFFIX;
273250757Sjkim    ACPI_MSG_REDIRECT_END;
274250757Sjkim}
275250757Sjkim
276250757Sjkim
277250757Sjkim/*******************************************************************************
278250757Sjkim *
279250757Sjkim * FUNCTION:    AcpiUtMethodError
280250757Sjkim *
281250757Sjkim * PARAMETERS:  ModuleName          - Caller's module name (for error output)
282250757Sjkim *              LineNumber          - Caller's line number (for error output)
283250757Sjkim *              Message             - Error message to use on failure
284250757Sjkim *              PrefixNode          - Prefix relative to the path
285250757Sjkim *              Path                - Path to the node (optional)
286250757Sjkim *              MethodStatus        - Execution status
287250757Sjkim *
288250757Sjkim * RETURN:      None
289250757Sjkim *
290250757Sjkim * DESCRIPTION: Print error message with the full pathname for the method.
291250757Sjkim *
292250757Sjkim ******************************************************************************/
293250757Sjkim
294250757Sjkimvoid
295250757SjkimAcpiUtMethodError (
296250757Sjkim    const char              *ModuleName,
297250757Sjkim    UINT32                  LineNumber,
298250757Sjkim    const char              *Message,
299250757Sjkim    ACPI_NAMESPACE_NODE     *PrefixNode,
300250757Sjkim    const char              *Path,
301250757Sjkim    ACPI_STATUS             MethodStatus)
302250757Sjkim{
303250757Sjkim    ACPI_STATUS             Status;
304250757Sjkim    ACPI_NAMESPACE_NODE     *Node = PrefixNode;
305250757Sjkim
306250757Sjkim
307250757Sjkim    ACPI_MSG_REDIRECT_BEGIN;
308250757Sjkim    AcpiOsPrintf (ACPI_MSG_ERROR);
309250757Sjkim
310250757Sjkim    if (Path)
311250757Sjkim    {
312250757Sjkim        Status = AcpiNsGetNode (PrefixNode, Path, ACPI_NS_NO_UPSEARCH,
313250757Sjkim                    &Node);
314250757Sjkim        if (ACPI_FAILURE (Status))
315250757Sjkim        {
316250757Sjkim            AcpiOsPrintf ("[Could not get node by pathname]");
317250757Sjkim        }
318250757Sjkim    }
319250757Sjkim
320250757Sjkim    AcpiNsPrintNodePathname (Node, Message);
321250757Sjkim    AcpiOsPrintf (", %s", AcpiFormatException (MethodStatus));
322250757Sjkim
323250757Sjkim    ACPI_MSG_SUFFIX;
324250757Sjkim    ACPI_MSG_REDIRECT_END;
325250757Sjkim}
326250757Sjkim
327250757Sjkim#endif /* ACPI_NO_ERROR_MESSAGES */
328