139224Sabial/******************************************************************************* 239224Sabial * 339224Sabial * Module Name: uterror - Various internal error/warning output functions 439224Sabial * 539224Sabial ******************************************************************************/ 639224Sabial 739224Sabial/* 839224Sabial * Copyright (C) 2000 - 2016, Intel Corp. 939224Sabial * All rights reserved. 1039224Sabial * 1139224Sabial * Redistribution and use in source and binary forms, with or without 1239224Sabial * modification, are permitted provided that the following conditions 1339224Sabial * are met: 1439224Sabial * 1. Redistributions of source code must retain the above copyright 1539224Sabial * notice, this list of conditions, and the following disclaimer, 1639224Sabial * without modification. 1739224Sabial * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1839224Sabial * substantially similar to the "NO WARRANTY" disclaimer below 1939224Sabial * ("Disclaimer") and any redistribution must be conditioned upon 2039224Sabial * including a substantially similar Disclaimer requirement for further 2139224Sabial * binary redistribution. 2239224Sabial * 3. Neither the names of the above-listed copyright holders nor the names 2339224Sabial * of any contributors may be used to endorse or promote products derived 2439224Sabial * from this software without specific prior written permission. 2539224Sabial * 2650479Speter * Alternatively, this software may be distributed under the terms of the 2739224Sabial * GNU General Public License ("GPL") version 2 as published by the Free 2839224Sabial * Software Foundation. 2939224Sabial * 3039224Sabial * NO WARRANTY 3139224Sabial * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3239224Sabial * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3339224Sabial * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3439224Sabial * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35173926Ssam * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3639224Sabial * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3739224Sabial * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3839224Sabial * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 3939224Sabial * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 4039224Sabial * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4139224Sabial * POSSIBILITY OF SUCH DAMAGES. 4239224Sabial */ 4339224Sabial 4479155Stmm#include <contrib/dev/acpica/include/acpi.h> 4539224Sabial#include <contrib/dev/acpica/include/accommon.h> 4639224Sabial#include <contrib/dev/acpica/include/acnamesp.h> 4739224Sabial 4839224Sabial 49173926Ssam#define _COMPONENT ACPI_UTILITIES 5039224Sabial ACPI_MODULE_NAME ("uterror") 5139224Sabial 5239224Sabial 5339224Sabial/* 5439224Sabial * This module contains internal error functions that may 55173926Ssam * be configured out. 5639224Sabial */ 5739224Sabial#if !defined (ACPI_NO_ERROR_MESSAGES) 5839224Sabial 5939224Sabial/******************************************************************************* 6039224Sabial * 6139224Sabial * FUNCTION: AcpiUtPredefinedWarning 6239224Sabial * 6339224Sabial * PARAMETERS: ModuleName - Caller's module name (for error output) 6439224Sabial * LineNumber - Caller's line number (for error output) 6539224Sabial * Pathname - Full pathname to the node 6639224Sabial * NodeFlags - From Namespace node for the method/object 6739224Sabial * Format - Printf format string + additional args 6839224Sabial * 6939224Sabial * RETURN: None 7039224Sabial * 7139224Sabial * DESCRIPTION: Warnings for the predefined validation module. Messages are 7239224Sabial * only emitted the first time a problem with a particular 7339224Sabial * method/object is detected. This prevents a flood of error 7439224Sabial * messages for methods that are repeatedly evaluated. 7539224Sabial * 76 ******************************************************************************/ 77 78void ACPI_INTERNAL_VAR_XFACE 79AcpiUtPredefinedWarning ( 80 const char *ModuleName, 81 UINT32 LineNumber, 82 char *Pathname, 83 UINT8 NodeFlags, 84 const char *Format, 85 ...) 86{ 87 va_list ArgList; 88 89 90 /* 91 * Warning messages for this method/object will be disabled after the 92 * first time a validation fails or an object is successfully repaired. 93 */ 94 if (NodeFlags & ANOBJ_EVALUATED) 95 { 96 return; 97 } 98 99 AcpiOsPrintf (ACPI_MSG_WARNING "%s: ", Pathname); 100 101 va_start (ArgList, Format); 102 AcpiOsVprintf (Format, ArgList); 103 ACPI_MSG_SUFFIX; 104 va_end (ArgList); 105} 106 107 108/******************************************************************************* 109 * 110 * FUNCTION: AcpiUtPredefinedInfo 111 * 112 * PARAMETERS: ModuleName - Caller's module name (for error output) 113 * LineNumber - Caller's line number (for error output) 114 * Pathname - Full pathname to the node 115 * NodeFlags - From Namespace node for the method/object 116 * Format - Printf format string + additional args 117 * 118 * RETURN: None 119 * 120 * DESCRIPTION: Info messages for the predefined validation module. Messages 121 * are only emitted the first time a problem with a particular 122 * method/object is detected. This prevents a flood of 123 * messages for methods that are repeatedly evaluated. 124 * 125 ******************************************************************************/ 126 127void ACPI_INTERNAL_VAR_XFACE 128AcpiUtPredefinedInfo ( 129 const char *ModuleName, 130 UINT32 LineNumber, 131 char *Pathname, 132 UINT8 NodeFlags, 133 const char *Format, 134 ...) 135{ 136 va_list ArgList; 137 138 139 /* 140 * Warning messages for this method/object will be disabled after the 141 * first time a validation fails or an object is successfully repaired. 142 */ 143 if (NodeFlags & ANOBJ_EVALUATED) 144 { 145 return; 146 } 147 148 AcpiOsPrintf (ACPI_MSG_INFO "%s: ", Pathname); 149 150 va_start (ArgList, Format); 151 AcpiOsVprintf (Format, ArgList); 152 ACPI_MSG_SUFFIX; 153 va_end (ArgList); 154} 155 156 157/******************************************************************************* 158 * 159 * FUNCTION: AcpiUtPredefinedBiosError 160 * 161 * PARAMETERS: ModuleName - Caller's module name (for error output) 162 * LineNumber - Caller's line number (for error output) 163 * Pathname - Full pathname to the node 164 * NodeFlags - From Namespace node for the method/object 165 * Format - Printf format string + additional args 166 * 167 * RETURN: None 168 * 169 * DESCRIPTION: BIOS error message for predefined names. Messages 170 * are only emitted the first time a problem with a particular 171 * method/object is detected. This prevents a flood of 172 * messages for methods that are repeatedly evaluated. 173 * 174 ******************************************************************************/ 175 176void ACPI_INTERNAL_VAR_XFACE 177AcpiUtPredefinedBiosError ( 178 const char *ModuleName, 179 UINT32 LineNumber, 180 char *Pathname, 181 UINT8 NodeFlags, 182 const char *Format, 183 ...) 184{ 185 va_list ArgList; 186 187 188 /* 189 * Warning messages for this method/object will be disabled after the 190 * first time a validation fails or an object is successfully repaired. 191 */ 192 if (NodeFlags & ANOBJ_EVALUATED) 193 { 194 return; 195 } 196 197 AcpiOsPrintf (ACPI_MSG_BIOS_ERROR "%s: ", Pathname); 198 199 va_start (ArgList, Format); 200 AcpiOsVprintf (Format, ArgList); 201 ACPI_MSG_SUFFIX; 202 va_end (ArgList); 203} 204 205 206/******************************************************************************* 207 * 208 * FUNCTION: AcpiUtNamespaceError 209 * 210 * PARAMETERS: ModuleName - Caller's module name (for error output) 211 * LineNumber - Caller's line number (for error output) 212 * InternalName - Name or path of the namespace node 213 * LookupStatus - Exception code from NS lookup 214 * 215 * RETURN: None 216 * 217 * DESCRIPTION: Print error message with the full pathname for the NS node. 218 * 219 ******************************************************************************/ 220 221void 222AcpiUtNamespaceError ( 223 const char *ModuleName, 224 UINT32 LineNumber, 225 const char *InternalName, 226 ACPI_STATUS LookupStatus) 227{ 228 ACPI_STATUS Status; 229 UINT32 BadName; 230 char *Name = NULL; 231 232 233 ACPI_MSG_REDIRECT_BEGIN; 234 AcpiOsPrintf (ACPI_MSG_ERROR); 235 236 if (LookupStatus == AE_BAD_CHARACTER) 237 { 238 /* There is a non-ascii character in the name */ 239 240 ACPI_MOVE_32_TO_32 (&BadName, ACPI_CAST_PTR (UINT32, InternalName)); 241 AcpiOsPrintf ("[0x%.8X] (NON-ASCII)", BadName); 242 } 243 else 244 { 245 /* Convert path to external format */ 246 247 Status = AcpiNsExternalizeName ( 248 ACPI_UINT32_MAX, InternalName, NULL, &Name); 249 250 /* Print target name */ 251 252 if (ACPI_SUCCESS (Status)) 253 { 254 AcpiOsPrintf ("[%s]", Name); 255 } 256 else 257 { 258 AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]"); 259 } 260 261 if (Name) 262 { 263 ACPI_FREE (Name); 264 } 265 } 266 267 AcpiOsPrintf (" Namespace lookup failure, %s", 268 AcpiFormatException (LookupStatus)); 269 270 ACPI_MSG_SUFFIX; 271 ACPI_MSG_REDIRECT_END; 272} 273 274 275/******************************************************************************* 276 * 277 * FUNCTION: AcpiUtMethodError 278 * 279 * PARAMETERS: ModuleName - Caller's module name (for error output) 280 * LineNumber - Caller's line number (for error output) 281 * Message - Error message to use on failure 282 * PrefixNode - Prefix relative to the path 283 * Path - Path to the node (optional) 284 * MethodStatus - Execution status 285 * 286 * RETURN: None 287 * 288 * DESCRIPTION: Print error message with the full pathname for the method. 289 * 290 ******************************************************************************/ 291 292void 293AcpiUtMethodError ( 294 const char *ModuleName, 295 UINT32 LineNumber, 296 const char *Message, 297 ACPI_NAMESPACE_NODE *PrefixNode, 298 const char *Path, 299 ACPI_STATUS MethodStatus) 300{ 301 ACPI_STATUS Status; 302 ACPI_NAMESPACE_NODE *Node = PrefixNode; 303 304 305 ACPI_MSG_REDIRECT_BEGIN; 306 AcpiOsPrintf (ACPI_MSG_ERROR); 307 308 if (Path) 309 { 310 Status = AcpiNsGetNode (PrefixNode, Path, 311 ACPI_NS_NO_UPSEARCH, &Node); 312 if (ACPI_FAILURE (Status)) 313 { 314 AcpiOsPrintf ("[Could not get node by pathname]"); 315 } 316 } 317 318 AcpiNsPrintNodePathname (Node, Message); 319 AcpiOsPrintf (", %s", AcpiFormatException (MethodStatus)); 320 321 ACPI_MSG_SUFFIX; 322 ACPI_MSG_REDIRECT_END; 323} 324 325#endif /* ACPI_NO_ERROR_MESSAGES */ 326