Path: blob/main/sys/contrib/dev/acpica/components/utilities/uterror.c
48406 views
/*******************************************************************************1*2* Module Name: uterror - Various internal error/warning output functions3*4******************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#include <contrib/dev/acpica/include/acpi.h>152#include <contrib/dev/acpica/include/accommon.h>153#include <contrib/dev/acpica/include/acnamesp.h>154155156#define _COMPONENT ACPI_UTILITIES157ACPI_MODULE_NAME ("uterror")158159160/*161* This module contains internal error functions that may162* be configured out.163*/164#if !defined (ACPI_NO_ERROR_MESSAGES)165166/*******************************************************************************167*168* FUNCTION: AcpiUtPredefinedWarning169*170* PARAMETERS: ModuleName - Caller's module name (for error output)171* LineNumber - Caller's line number (for error output)172* Pathname - Full pathname to the node173* NodeFlags - From Namespace node for the method/object174* Format - Printf format string + additional args175*176* RETURN: None177*178* DESCRIPTION: Warnings for the predefined validation module. Messages are179* only emitted the first time a problem with a particular180* method/object is detected. This prevents a flood of error181* messages for methods that are repeatedly evaluated.182*183******************************************************************************/184185void ACPI_INTERNAL_VAR_XFACE186AcpiUtPredefinedWarning (187const char *ModuleName,188UINT32 LineNumber,189char *Pathname,190UINT16 NodeFlags,191const char *Format,192...)193{194va_list ArgList;195196197/*198* Warning messages for this method/object will be disabled after the199* first time a validation fails or an object is successfully repaired.200*/201if (NodeFlags & ANOBJ_EVALUATED)202{203return;204}205206AcpiOsPrintf (ACPI_MSG_WARNING "%s: ", Pathname);207208va_start (ArgList, Format);209AcpiOsVprintf (Format, ArgList);210ACPI_MSG_SUFFIX;211va_end (ArgList);212}213214215/*******************************************************************************216*217* FUNCTION: AcpiUtPredefinedInfo218*219* PARAMETERS: ModuleName - Caller's module name (for error output)220* LineNumber - Caller's line number (for error output)221* Pathname - Full pathname to the node222* NodeFlags - From Namespace node for the method/object223* Format - Printf format string + additional args224*225* RETURN: None226*227* DESCRIPTION: Info messages for the predefined validation module. Messages228* are only emitted the first time a problem with a particular229* method/object is detected. This prevents a flood of230* messages for methods that are repeatedly evaluated.231*232******************************************************************************/233234void ACPI_INTERNAL_VAR_XFACE235AcpiUtPredefinedInfo (236const char *ModuleName,237UINT32 LineNumber,238char *Pathname,239UINT16 NodeFlags,240const char *Format,241...)242{243va_list ArgList;244245246/*247* Warning messages for this method/object will be disabled after the248* first time a validation fails or an object is successfully repaired.249*/250if (NodeFlags & ANOBJ_EVALUATED)251{252return;253}254255AcpiOsPrintf (ACPI_MSG_INFO "%s: ", Pathname);256257va_start (ArgList, Format);258AcpiOsVprintf (Format, ArgList);259ACPI_MSG_SUFFIX;260va_end (ArgList);261}262263264/*******************************************************************************265*266* FUNCTION: AcpiUtPredefinedBiosError267*268* PARAMETERS: ModuleName - Caller's module name (for error output)269* LineNumber - Caller's line number (for error output)270* Pathname - Full pathname to the node271* NodeFlags - From Namespace node for the method/object272* Format - Printf format string + additional args273*274* RETURN: None275*276* DESCRIPTION: BIOS error message for predefined names. Messages277* are only emitted the first time a problem with a particular278* method/object is detected. This prevents a flood of279* messages for methods that are repeatedly evaluated.280*281******************************************************************************/282283void ACPI_INTERNAL_VAR_XFACE284AcpiUtPredefinedBiosError (285const char *ModuleName,286UINT32 LineNumber,287char *Pathname,288UINT16 NodeFlags,289const char *Format,290...)291{292va_list ArgList;293294295/*296* Warning messages for this method/object will be disabled after the297* first time a validation fails or an object is successfully repaired.298*/299if (NodeFlags & ANOBJ_EVALUATED)300{301return;302}303304AcpiOsPrintf (ACPI_MSG_BIOS_ERROR "%s: ", Pathname);305306va_start (ArgList, Format);307AcpiOsVprintf (Format, ArgList);308ACPI_MSG_SUFFIX;309va_end (ArgList);310}311312313/*******************************************************************************314*315* FUNCTION: AcpiUtPrefixedNamespaceError316*317* PARAMETERS: ModuleName - Caller's module name (for error output)318* LineNumber - Caller's line number (for error output)319* PrefixScope - Scope/Path that prefixes the internal path320* InternalPath - Name or path of the namespace node321* LookupStatus - Exception code from NS lookup322*323* RETURN: None324*325* DESCRIPTION: Print error message with the full pathname constructed this way:326*327* PrefixScopeNodeFullPath.ExternalizedInternalPath328*329* NOTE: 10/2017: Treat the major NsLookup errors as firmware errors330*331******************************************************************************/332333void334AcpiUtPrefixedNamespaceError (335const char *ModuleName,336UINT32 LineNumber,337ACPI_GENERIC_STATE *PrefixScope,338const char *InternalPath,339ACPI_STATUS LookupStatus)340{341char *FullPath;342const char *Message;343344345/*346* Main cases:347* 1) Object creation, object must not already exist348* 2) Object lookup, object must exist349*/350switch (LookupStatus)351{352case AE_ALREADY_EXISTS:353354AcpiOsPrintf (ACPI_MSG_BIOS_ERROR);355Message = "Failure creating named object";356break;357358case AE_NOT_FOUND:359360AcpiOsPrintf (ACPI_MSG_BIOS_ERROR);361Message = "Could not resolve symbol";362break;363364default:365366AcpiOsPrintf (ACPI_MSG_ERROR);367Message = "Failure resolving symbol";368break;369}370371/* Concatenate the prefix path and the internal path */372373FullPath = AcpiNsBuildPrefixedPathname (PrefixScope, InternalPath);374375AcpiOsPrintf ("%s [%s], %s", Message,376FullPath ? FullPath : "Could not get pathname",377AcpiFormatException (LookupStatus));378379if (FullPath)380{381ACPI_FREE (FullPath);382}383384ACPI_MSG_SUFFIX;385}386387388#ifdef __OBSOLETE_FUNCTION389/*******************************************************************************390*391* FUNCTION: AcpiUtNamespaceError392*393* PARAMETERS: ModuleName - Caller's module name (for error output)394* LineNumber - Caller's line number (for error output)395* InternalName - Name or path of the namespace node396* LookupStatus - Exception code from NS lookup397*398* RETURN: None399*400* DESCRIPTION: Print error message with the full pathname for the NS node.401*402******************************************************************************/403404void405AcpiUtNamespaceError (406const char *ModuleName,407UINT32 LineNumber,408const char *InternalName,409ACPI_STATUS LookupStatus)410{411ACPI_STATUS Status;412UINT32 BadName;413char *Name = NULL;414415416ACPI_MSG_REDIRECT_BEGIN;417AcpiOsPrintf (ACPI_MSG_ERROR);418419if (LookupStatus == AE_BAD_CHARACTER)420{421/* There is a non-ascii character in the name */422423ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName));424AcpiOsPrintf ("[0x%.8X] (NON-ASCII)", BadName);425}426else427{428/* Convert path to external format */429430Status = AcpiNsExternalizeName (431ACPI_UINT32_MAX, InternalName, NULL, &Name);432433/* Print target name */434435if (ACPI_SUCCESS (Status))436{437AcpiOsPrintf ("[%s]", Name);438}439else440{441AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]");442}443444if (Name)445{446ACPI_FREE (Name);447}448}449450AcpiOsPrintf (" Namespace lookup failure, %s",451AcpiFormatException (LookupStatus));452453ACPI_MSG_SUFFIX;454ACPI_MSG_REDIRECT_END;455}456#endif457458/*******************************************************************************459*460* FUNCTION: AcpiUtMethodError461*462* PARAMETERS: ModuleName - Caller's module name (for error output)463* LineNumber - Caller's line number (for error output)464* Message - Error message to use on failure465* PrefixNode - Prefix relative to the path466* Path - Path to the node (optional)467* MethodStatus - Execution status468*469* RETURN: None470*471* DESCRIPTION: Print error message with the full pathname for the method.472*473******************************************************************************/474475void476AcpiUtMethodError (477const char *ModuleName,478UINT32 LineNumber,479const char *Message,480ACPI_NAMESPACE_NODE *PrefixNode,481const char *Path,482ACPI_STATUS MethodStatus)483{484ACPI_STATUS Status;485ACPI_NAMESPACE_NODE *Node = PrefixNode;486487488ACPI_MSG_REDIRECT_BEGIN;489AcpiOsPrintf (ACPI_MSG_ERROR);490491if (Path)492{493Status = AcpiNsGetNode (PrefixNode, Path,494ACPI_NS_NO_UPSEARCH, &Node);495if (ACPI_FAILURE (Status))496{497AcpiOsPrintf ("[Could not get node by pathname]");498}499}500501AcpiNsPrintNodePathname (Node, Message);502AcpiOsPrintf (" due to previous error (%s)",503AcpiFormatException (MethodStatus));504505ACPI_MSG_SUFFIX;506ACPI_MSG_REDIRECT_END;507}508509#endif /* ACPI_NO_ERROR_MESSAGES */510511512