utexcep.c revision 7b1019a6d29ccb7999dc76cba3dde1c627e8e609
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek/*******************************************************************************
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * Module Name: utexcep - Exception code support
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek ******************************************************************************/
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek/*
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * Copyright (C) 2000 - 2016, Intel Corp.
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * All rights reserved.
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * Redistribution and use in source and binary forms, with or without
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * modification, are permitted provided that the following conditions
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * are met:
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * 1. Redistributions of source code must retain the above copyright
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * notice, this list of conditions, and the following disclaimer,
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * without modification.
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * 2. Redistributions in binary form must reproduce at minimum a disclaimer
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * substantially similar to the "NO WARRANTY" disclaimer below
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * ("Disclaimer") and any redistribution must be conditioned upon
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * including a substantially similar Disclaimer requirement for further
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * binary redistribution.
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * 3. Neither the names of the above-listed copyright holders nor the names
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * of any contributors may be used to endorse or promote products derived
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * from this software without specific prior written permission.
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * Alternatively, this software may be distributed under the terms of the
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * GNU General Public License ("GPL") version 2 as published by the Free
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * Software Foundation.
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * NO WARRANTY
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * POSSIBILITY OF SUCH DAMAGES.
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek */
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek#define EXPORT_ACPI_INTERFACES
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek#define ACPI_DEFINE_EXCEPTION_TABLE
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek#include "acpi.h"
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek#include "accommon.h"
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek#define _COMPONENT ACPI_UTILITIES
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek ACPI_MODULE_NAME ("utexcep")
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek/*******************************************************************************
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * FUNCTION: AcpiFormatException
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * PARAMETERS: Status - The ACPI_STATUS code to be formatted
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * RETURN: A string containing the exception text. A valid pointer is
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * always returned.
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * DESCRIPTION: This function translates an ACPI exception into an ASCII
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * string. Returns "unknown status" string for invalid codes.
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek ******************************************************************************/
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinekconst char *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry JelinekAcpiFormatException (
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek ACPI_STATUS Status)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek{
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek const ACPI_EXCEPTION_INFO *Exception;
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek ACPI_FUNCTION_ENTRY ();
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek Exception = AcpiUtValidateException (Status);
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek if (!Exception)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek {
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek /* Exception code was not recognized */
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek ACPI_ERROR ((AE_INFO,
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek "Unknown exception code: 0x%8.8X", Status));
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek return ("UNKNOWN_STATUS_CODE");
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek }
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek return (Exception->Name);
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek}
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry JelinekACPI_EXPORT_SYMBOL (AcpiFormatException)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek/*******************************************************************************
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * FUNCTION: AcpiUtValidateException
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * PARAMETERS: Status - The ACPI_STATUS code to be formatted
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * RETURN: A string containing the exception text. NULL if exception is
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * not valid.
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * DESCRIPTION: This function validates and translates an ACPI exception into
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * an ASCII string.
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek ******************************************************************************/
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinekconst ACPI_EXCEPTION_INFO *
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry JelinekAcpiUtValidateException (
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek ACPI_STATUS Status)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek{
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek UINT32 SubStatus;
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek const ACPI_EXCEPTION_INFO *Exception = NULL;
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek ACPI_FUNCTION_ENTRY ();
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek /*
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek * Status is composed of two parts, a "type" and an actual code
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek */
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek SubStatus = (Status & ~AE_CODE_MASK);
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek switch (Status & AE_CODE_MASK)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek {
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek case AE_CODE_ENVIRONMENTAL:
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek if (SubStatus <= AE_CODE_ENV_MAX)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek {
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek Exception = &AcpiGbl_ExceptionNames_Env [SubStatus];
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek }
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek break;
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek case AE_CODE_PROGRAMMER:
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek if (SubStatus <= AE_CODE_PGM_MAX)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek {
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek Exception = &AcpiGbl_ExceptionNames_Pgm [SubStatus];
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek }
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek break;
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek case AE_CODE_ACPI_TABLES:
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek if (SubStatus <= AE_CODE_TBL_MAX)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek {
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek Exception = &AcpiGbl_ExceptionNames_Tbl [SubStatus];
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek }
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek break;
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek case AE_CODE_AML:
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek if (SubStatus <= AE_CODE_AML_MAX)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek {
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek Exception = &AcpiGbl_ExceptionNames_Aml [SubStatus];
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek }
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek break;
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek case AE_CODE_CONTROL:
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek if (SubStatus <= AE_CODE_CTRL_MAX)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek {
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek Exception = &AcpiGbl_ExceptionNames_Ctrl [SubStatus];
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek }
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek break;
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek default:
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek break;
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek }
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek if (!Exception || !Exception->Name)
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek {
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek return (NULL);
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek }
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek return (Exception);
7b1019a6d29ccb7999dc76cba3dde1c627e8e609Jerry Jelinek}