utmisc.c revision 5df7e6cb42da36c7d878239bebc81907b15f3943
11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Module Name: utmisc - common utility procedures 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 8a8357b0c95484b46944728712f8810d3b37bf588Bob Moore * Copyright (C) 2000 - 2010, Intel Corp. 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * All rights reserved. 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Redistribution and use in source and binary forms, with or without 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * modification, are permitted provided that the following conditions 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * are met: 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1. Redistributions of source code must retain the above copyright 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * notice, this list of conditions, and the following disclaimer, 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * without modification. 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2. Redistributions in binary form must reproduce at minimum a disclaimer 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * substantially similar to the "NO WARRANTY" disclaimer below 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * ("Disclaimer") and any redistribution must be conditioned upon 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * including a substantially similar Disclaimer requirement for further 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * binary redistribution. 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3. Neither the names of the above-listed copyright holders nor the names 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * of any contributors may be used to endorse or promote products derived 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * from this software without specific prior written permission. 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Alternatively, this software may be distributed under the terms of the 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * GNU General Public License ("GPL") version 2 as published by the Free 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Software Foundation. 291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NO WARRANTY 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * POSSIBILITY OF SUCH DAMAGES. 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 44be63c925a123b492fc05063c98ca7e9f7453a58aThomas Renninger#include <linux/module.h> 45be63c925a123b492fc05063c98ca7e9f7453a58aThomas Renninger 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <acpi/acpi.h> 47e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "accommon.h" 48e2f7a7772880458edff1b1cc5a988947229fac26Len Brown#include "acnamesp.h" 491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _COMPONENT ACPI_UTILITIES 514be44fcd3bf648b782f4460fd06dfae6c42ded4bLen BrownACPI_MODULE_NAME("utmisc") 5244f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore 530444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore/* 540444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * Common suffix for messages 550444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore */ 560444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore#define ACPI_COMMON_MSG_SUFFIX \ 578d590c7af1152685efcf302905baeb6dda3c2d2fBob Moore acpi_os_printf(" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number) 5844f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore/******************************************************************************* 5944f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * 6084fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * FUNCTION: acpi_ut_validate_exception 6184fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * 6284fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * PARAMETERS: Status - The acpi_status code to be formatted 6384fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * 6484fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * RETURN: A string containing the exception text. NULL if exception is 6584fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * not valid. 6684fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * 6784fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * DESCRIPTION: This function validates and translates an ACPI exception into 6884fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * an ASCII string. 6984fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * 7084fb2c97731c1631c5548c15f3698ad82c274245Bob Moore ******************************************************************************/ 7184fb2c97731c1631c5548c15f3698ad82c274245Bob Mooreconst char *acpi_ut_validate_exception(acpi_status status) 7284fb2c97731c1631c5548c15f3698ad82c274245Bob Moore{ 7311f2a61ab418305167f9a3f3a31a50449222f64bBob Moore u32 sub_status; 7484fb2c97731c1631c5548c15f3698ad82c274245Bob Moore const char *exception = NULL; 7584fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 7684fb2c97731c1631c5548c15f3698ad82c274245Bob Moore ACPI_FUNCTION_ENTRY(); 7784fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 7884fb2c97731c1631c5548c15f3698ad82c274245Bob Moore /* 7984fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * Status is composed of two parts, a "type" and an actual code 8084fb2c97731c1631c5548c15f3698ad82c274245Bob Moore */ 8184fb2c97731c1631c5548c15f3698ad82c274245Bob Moore sub_status = (status & ~AE_CODE_MASK); 8284fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 8384fb2c97731c1631c5548c15f3698ad82c274245Bob Moore switch (status & AE_CODE_MASK) { 8484fb2c97731c1631c5548c15f3698ad82c274245Bob Moore case AE_CODE_ENVIRONMENTAL: 8584fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 8684fb2c97731c1631c5548c15f3698ad82c274245Bob Moore if (sub_status <= AE_CODE_ENV_MAX) { 8784fb2c97731c1631c5548c15f3698ad82c274245Bob Moore exception = acpi_gbl_exception_names_env[sub_status]; 8884fb2c97731c1631c5548c15f3698ad82c274245Bob Moore } 8984fb2c97731c1631c5548c15f3698ad82c274245Bob Moore break; 9084fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 9184fb2c97731c1631c5548c15f3698ad82c274245Bob Moore case AE_CODE_PROGRAMMER: 9284fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 9384fb2c97731c1631c5548c15f3698ad82c274245Bob Moore if (sub_status <= AE_CODE_PGM_MAX) { 9411f2a61ab418305167f9a3f3a31a50449222f64bBob Moore exception = acpi_gbl_exception_names_pgm[sub_status]; 9584fb2c97731c1631c5548c15f3698ad82c274245Bob Moore } 9684fb2c97731c1631c5548c15f3698ad82c274245Bob Moore break; 9784fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 9884fb2c97731c1631c5548c15f3698ad82c274245Bob Moore case AE_CODE_ACPI_TABLES: 9984fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 10084fb2c97731c1631c5548c15f3698ad82c274245Bob Moore if (sub_status <= AE_CODE_TBL_MAX) { 10111f2a61ab418305167f9a3f3a31a50449222f64bBob Moore exception = acpi_gbl_exception_names_tbl[sub_status]; 10284fb2c97731c1631c5548c15f3698ad82c274245Bob Moore } 10384fb2c97731c1631c5548c15f3698ad82c274245Bob Moore break; 10484fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 10584fb2c97731c1631c5548c15f3698ad82c274245Bob Moore case AE_CODE_AML: 10684fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 10784fb2c97731c1631c5548c15f3698ad82c274245Bob Moore if (sub_status <= AE_CODE_AML_MAX) { 10811f2a61ab418305167f9a3f3a31a50449222f64bBob Moore exception = acpi_gbl_exception_names_aml[sub_status]; 10984fb2c97731c1631c5548c15f3698ad82c274245Bob Moore } 11084fb2c97731c1631c5548c15f3698ad82c274245Bob Moore break; 11184fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 11284fb2c97731c1631c5548c15f3698ad82c274245Bob Moore case AE_CODE_CONTROL: 11384fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 11484fb2c97731c1631c5548c15f3698ad82c274245Bob Moore if (sub_status <= AE_CODE_CTRL_MAX) { 11511f2a61ab418305167f9a3f3a31a50449222f64bBob Moore exception = acpi_gbl_exception_names_ctrl[sub_status]; 11684fb2c97731c1631c5548c15f3698ad82c274245Bob Moore } 11784fb2c97731c1631c5548c15f3698ad82c274245Bob Moore break; 11884fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 11984fb2c97731c1631c5548c15f3698ad82c274245Bob Moore default: 12084fb2c97731c1631c5548c15f3698ad82c274245Bob Moore break; 12184fb2c97731c1631c5548c15f3698ad82c274245Bob Moore } 12284fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 12384fb2c97731c1631c5548c15f3698ad82c274245Bob Moore return (ACPI_CAST_PTR(const char, exception)); 12484fb2c97731c1631c5548c15f3698ad82c274245Bob Moore} 12584fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 12684fb2c97731c1631c5548c15f3698ad82c274245Bob Moore/******************************************************************************* 12784fb2c97731c1631c5548c15f3698ad82c274245Bob Moore * 12815b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * FUNCTION: acpi_ut_is_pci_root_bridge 12915b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * 13015b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * PARAMETERS: Id - The HID/CID in string format 13115b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * 13215b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge 13315b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * 13415b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. 13515b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * 13615b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore ******************************************************************************/ 13715b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore 13815b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Mooreu8 acpi_ut_is_pci_root_bridge(char *id) 13915b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore{ 14015b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore 14115b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore /* 14215b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * Check if this is a PCI root bridge. 14315b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * ACPI 3.0+: check for a PCI Express root also. 14415b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore */ 14515b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore if (!(ACPI_STRCMP(id, 14615b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore PCI_ROOT_HID_STRING)) || 14715b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore !(ACPI_STRCMP(id, PCI_EXPRESS_ROOT_HID_STRING))) { 14815b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore return (TRUE); 14915b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore } 15015b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore 15115b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore return (FALSE); 15215b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore} 15315b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore 15415b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore/******************************************************************************* 15515b8dd53f5ffaf8e2d9095c423f713423f576c0fBob Moore * 156793c2388cae3fd023b3b5166354931752d42353cBob Moore * FUNCTION: acpi_ut_is_aml_table 157793c2388cae3fd023b3b5166354931752d42353cBob Moore * 158793c2388cae3fd023b3b5166354931752d42353cBob Moore * PARAMETERS: Table - An ACPI table 159793c2388cae3fd023b3b5166354931752d42353cBob Moore * 160793c2388cae3fd023b3b5166354931752d42353cBob Moore * RETURN: TRUE if table contains executable AML; FALSE otherwise 161793c2388cae3fd023b3b5166354931752d42353cBob Moore * 162793c2388cae3fd023b3b5166354931752d42353cBob Moore * DESCRIPTION: Check ACPI Signature for a table that contains AML code. 163793c2388cae3fd023b3b5166354931752d42353cBob Moore * Currently, these are DSDT,SSDT,PSDT. All other table types are 164793c2388cae3fd023b3b5166354931752d42353cBob Moore * data tables that do not contain AML code. 165793c2388cae3fd023b3b5166354931752d42353cBob Moore * 166793c2388cae3fd023b3b5166354931752d42353cBob Moore ******************************************************************************/ 16784fb2c97731c1631c5548c15f3698ad82c274245Bob Moore 168793c2388cae3fd023b3b5166354931752d42353cBob Mooreu8 acpi_ut_is_aml_table(struct acpi_table_header *table) 169793c2388cae3fd023b3b5166354931752d42353cBob Moore{ 170793c2388cae3fd023b3b5166354931752d42353cBob Moore 171f6dd9221dddb3550e60d32aee688588ec208312cBob Moore /* These are the only tables that contain executable AML */ 172793c2388cae3fd023b3b5166354931752d42353cBob Moore 173f3d2e7865c816258c699ff965768e46b50d536d3Bob Moore if (ACPI_COMPARE_NAME(table->signature, ACPI_SIG_DSDT) || 174f3d2e7865c816258c699ff965768e46b50d536d3Bob Moore ACPI_COMPARE_NAME(table->signature, ACPI_SIG_PSDT) || 175f3d2e7865c816258c699ff965768e46b50d536d3Bob Moore ACPI_COMPARE_NAME(table->signature, ACPI_SIG_SSDT)) { 176793c2388cae3fd023b3b5166354931752d42353cBob Moore return (TRUE); 177793c2388cae3fd023b3b5166354931752d42353cBob Moore } 178793c2388cae3fd023b3b5166354931752d42353cBob Moore 179793c2388cae3fd023b3b5166354931752d42353cBob Moore return (FALSE); 180793c2388cae3fd023b3b5166354931752d42353cBob Moore} 181793c2388cae3fd023b3b5166354931752d42353cBob Moore 182793c2388cae3fd023b3b5166354931752d42353cBob Moore/******************************************************************************* 183793c2388cae3fd023b3b5166354931752d42353cBob Moore * 184f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * FUNCTION: acpi_ut_allocate_owner_id 185f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * 186f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * PARAMETERS: owner_id - Where the new owner ID is returned 187f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * 1880c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore * RETURN: Status 1890c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore * 1900c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to 1910c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore * track objects created by the table or method, to be deleted 1920c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore * when the method exits or the table is unloaded. 193f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * 194f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore ******************************************************************************/ 195793c2388cae3fd023b3b5166354931752d42353cBob Moore 1964be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) 197f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore{ 19867a119f990063f5662574f6d6414fe9bc5ece86aBob Moore u32 i; 19967a119f990063f5662574f6d6414fe9bc5ece86aBob Moore u32 j; 20067a119f990063f5662574f6d6414fe9bc5ece86aBob Moore u32 k; 2014be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status; 202f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 203b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore ACPI_FUNCTION_TRACE(ut_allocate_owner_id); 204f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 205aff8c2777d1a9edf97f26bf60579f9c931443eb1Robert Moore /* Guard against multiple allocations of ID to the same location */ 206aff8c2777d1a9edf97f26bf60579f9c931443eb1Robert Moore 207aff8c2777d1a9edf97f26bf60579f9c931443eb1Robert Moore if (*owner_id) { 208b8e4d89357fc434618a59c1047cac72641191805Bob Moore ACPI_ERROR((AE_INFO, "Owner ID [%2.2X] already exists", 209b8e4d89357fc434618a59c1047cac72641191805Bob Moore *owner_id)); 210aff8c2777d1a9edf97f26bf60579f9c931443eb1Robert Moore return_ACPI_STATUS(AE_ALREADY_EXISTS); 211aff8c2777d1a9edf97f26bf60579f9c931443eb1Robert Moore } 212aff8c2777d1a9edf97f26bf60579f9c931443eb1Robert Moore 2130c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore /* Mutex for the global ID mask */ 2140c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore 2154be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); 2164be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 2174be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(status); 218f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore } 219f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 220c51a4de85de720670f2fbc592a6f8040af72ad87Bob Moore /* 221c51a4de85de720670f2fbc592a6f8040af72ad87Bob Moore * Find a free owner ID, cycle through all possible IDs on repeated 22228f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have 22328f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore * to be scanned twice. 224c51a4de85de720670f2fbc592a6f8040af72ad87Bob Moore */ 22528f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore for (i = 0, j = acpi_gbl_last_owner_id_index; 22628f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore i < (ACPI_NUM_OWNERID_MASKS + 1); i++, j++) { 22728f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore if (j >= ACPI_NUM_OWNERID_MASKS) { 22828f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore j = 0; /* Wraparound to start of mask array */ 229c51a4de85de720670f2fbc592a6f8040af72ad87Bob Moore } 230c51a4de85de720670f2fbc592a6f8040af72ad87Bob Moore 23128f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore for (k = acpi_gbl_next_owner_id_offset; k < 32; k++) { 23228f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore if (acpi_gbl_owner_id_mask[j] == ACPI_UINT32_MAX) { 23352fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 23428f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore /* There are no free IDs in this mask */ 23528f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore 23628f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore break; 23728f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore } 23828f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore 23928f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore if (!(acpi_gbl_owner_id_mask[j] & (1 << k))) { 24028f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore /* 24128f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore * Found a free ID. The actual ID is the bit index plus one, 24228f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore * making zero an invalid Owner ID. Save this as the last ID 24328f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore * allocated and update the global ID mask. 24428f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore */ 24528f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore acpi_gbl_owner_id_mask[j] |= (1 << k); 24628f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore 24728f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore acpi_gbl_last_owner_id_index = (u8) j; 24828f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore acpi_gbl_next_owner_id_offset = (u8) (k + 1); 24928f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore 25028f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore /* 25128f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore * Construct encoded ID from the index and bit position 25228f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore * 25328f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore * Note: Last [j].k (bit 255) is never used and is marked 25428f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore * permanently allocated (prevents +1 overflow) 25528f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore */ 25628f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore *owner_id = 25728f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore (acpi_owner_id) ((k + 1) + ACPI_MUL_32(j)); 25828f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore 25928f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore ACPI_DEBUG_PRINT((ACPI_DB_VALUES, 260b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore "Allocated OwnerId: %2.2X\n", 26128f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore (unsigned int)*owner_id)); 26228f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore goto exit; 26328f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore } 264f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore } 26528f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore 26628f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore acpi_gbl_next_owner_id_offset = 0; 267f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore } 268f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 269f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore /* 270c51a4de85de720670f2fbc592a6f8040af72ad87Bob Moore * All owner_ids have been allocated. This typically should 271f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * not happen since the IDs are reused after deallocation. The IDs are 272f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * allocated upon table load (one per table) and method execution, and 273f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * they are released when a table is unloaded or a method completes 274f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * execution. 275c51a4de85de720670f2fbc592a6f8040af72ad87Bob Moore * 276c51a4de85de720670f2fbc592a6f8040af72ad87Bob Moore * If this error happens, there may be very deep nesting of invoked control 277c51a4de85de720670f2fbc592a6f8040af72ad87Bob Moore * methods, or there may be a bug where the IDs are not released. 278f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore */ 279f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore status = AE_OWNER_ID_LIMIT; 280b8e4d89357fc434618a59c1047cac72641191805Bob Moore ACPI_ERROR((AE_INFO, 281b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT")); 282f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 2834be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown exit: 2844be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); 2854be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(status); 286f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore} 287f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 288f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore/******************************************************************************* 289f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * 290f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * FUNCTION: acpi_ut_release_owner_id 291f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * 2920c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_iD 293f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * 2940c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore * RETURN: None. No error is returned because we are either exiting a 2950c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore * control method or unloading a table. Either way, we would 2960c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore * ignore any error anyway. 2970c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore * 29828f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 299f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * 300f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore ******************************************************************************/ 301f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 3024be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownvoid acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr) 303f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore{ 3044be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_owner_id owner_id = *owner_id_ptr; 3054be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status; 30667a119f990063f5662574f6d6414fe9bc5ece86aBob Moore u32 index; 30728f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore u32 bit; 308f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 309b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore ACPI_FUNCTION_TRACE_U32(ut_release_owner_id, owner_id); 310f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 3110c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore /* Always clear the input owner_id (zero is an invalid ID) */ 3120c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore 3130c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore *owner_id_ptr = 0; 3140c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore 3150c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore /* Zero is not a valid owner_iD */ 3160c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore 317defba1d8f233c0d5cf3e1ea6aeb898eca7231860Bob Moore if (owner_id == 0) { 318b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore ACPI_ERROR((AE_INFO, "Invalid OwnerId: %2.2X", owner_id)); 3190c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore return_VOID; 3200c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore } 3210c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore 3220c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore /* Mutex for the global ID mask */ 3230c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore 3244be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES); 3254be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 3260c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore return_VOID; 327f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore } 328f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 329aff8c2777d1a9edf97f26bf60579f9c931443eb1Robert Moore /* Normalize the ID to zero */ 330aff8c2777d1a9edf97f26bf60579f9c931443eb1Robert Moore 331aff8c2777d1a9edf97f26bf60579f9c931443eb1Robert Moore owner_id--; 3320c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore 33328f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore /* Decode ID to index/offset pair */ 33428f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore 33528f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore index = ACPI_DIV_32(owner_id); 33628f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore bit = 1 << ACPI_MOD_32(owner_id); 33728f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore 3380c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore /* Free the owner ID only if it is valid */ 339f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 34028f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore if (acpi_gbl_owner_id_mask[index] & bit) { 34128f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore acpi_gbl_owner_id_mask[index] ^= bit; 34228f55ebce5bd2fceec8adc7c8860953d3e4532a8Bob Moore } else { 343b8e4d89357fc434618a59c1047cac72641191805Bob Moore ACPI_ERROR((AE_INFO, 344b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore "Release of non-allocated OwnerId: %2.2X", 345b8e4d89357fc434618a59c1047cac72641191805Bob Moore owner_id + 1)); 346f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore } 347f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 3484be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); 3490c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore return_VOID; 350f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore} 351f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore 352f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore/******************************************************************************* 353f9f4601f331aa1226d7a798a01950efbb388f07fRobert Moore * 35444f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * FUNCTION: acpi_ut_strupr (strupr) 35544f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * 35644f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * PARAMETERS: src_string - The source string to convert 35744f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * 3580c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore * RETURN: None 35944f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * 36044f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * DESCRIPTION: Convert string to uppercase 36144f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * 36244f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * NOTE: This is not a POSIX function, so it appears here, not in utclib.c 36344f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * 36444f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore ******************************************************************************/ 36544f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore 3664be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownvoid acpi_ut_strupr(char *src_string) 36744f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore{ 3684be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown char *string; 36944f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore 3704be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_ENTRY(); 37144f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore 37273459f73e5d1602c59ebec114fc45185521353c1Robert Moore if (!src_string) { 3730c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore return; 37473459f73e5d1602c59ebec114fc45185521353c1Robert Moore } 37573459f73e5d1602c59ebec114fc45185521353c1Robert Moore 37644f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore /* Walk entire string, uppercasing the letters */ 37744f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore 37844f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore for (string = src_string; *string; string++) { 3794be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown *string = (char)ACPI_TOUPPER(*string); 38044f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore } 38144f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore 3820c9938cc75057c0fca1af55a55dcfc2842436695Robert Moore return; 38344f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore} 38444f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore 3851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 3861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_print_string 3881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: String - Null terminated ASCII string 39044f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * max_length - Maximum output length 3911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: None 3931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape 3951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * sequences. 3961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 3981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3994be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownvoid acpi_ut_print_string(char *string, u8 max_length) 4001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 4014be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 i; 4021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!string) { 4044be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("<\"NULL STRING PTR\">"); 4051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return; 4061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4084be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\""); 4091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds for (i = 0; string[i] && (i < max_length); i++) { 41052fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 4111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Escape sequences */ 4121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds switch (string[i]) { 4141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 0x07: 4154be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\\a"); /* BELL */ 4161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 4171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 0x08: 4194be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\\b"); /* BACKSPACE */ 4201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 4211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 0x0C: 4234be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\\f"); /* FORMFEED */ 4241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 4251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 0x0A: 4274be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\\n"); /* LINEFEED */ 4281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 4291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 0x0D: 4314be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\\r"); /* CARRIAGE RETURN */ 4321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 4331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 0x09: 4354be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\\t"); /* HORIZONTAL TAB */ 4361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 4371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 0x0B: 4394be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\\v"); /* VERTICAL TAB */ 4401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 4411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4424be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown case '\'': /* Single Quote */ 4434be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown case '\"': /* Double Quote */ 4444be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown case '\\': /* Backslash */ 4454be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\\%c", (int)string[i]); 4461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 4471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds default: 4491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Check for printable character or hex escape */ 4511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4524be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_IS_PRINT(string[i])) { 4531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* This is a normal character */ 4541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4554be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("%c", (int)string[i]); 4564be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown } else { 4571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* All others will be Hex escapes */ 4581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4594be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\\x%2.2X", (s32) string[i]); 4601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 4621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4644be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\""); 4651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (i == max_length && string[i]) { 4674be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("..."); 4681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 4691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 4701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 4721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_dword_byte_swap 4741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: Value - Value to be converted 4761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 47744f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * RETURN: u32 integer with bytes swapped 47844f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * 4791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) 4801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 4811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 4821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4834be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownu32 acpi_ut_dword_byte_swap(u32 value) 4841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 4851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds union { 4864be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 value; 4874be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u8 bytes[4]; 4881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } out; 4891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds union { 4904be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 value; 4914be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u8 bytes[4]; 4921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } in; 4931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4944be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_ENTRY(); 4951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds in.value = value; 4971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 4981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds out.bytes[0] = in.bytes[3]; 4991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds out.bytes[1] = in.bytes[2]; 5001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds out.bytes[2] = in.bytes[1]; 5011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds out.bytes[3] = in.bytes[0]; 5021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (out.value); 5041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 5051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 5071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 5081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_set_integer_width 5091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 5101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: Revision From DSDT header 5111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 5121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: None 5131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 5141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Set the global integer bit width based upon the revision 5151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * of the DSDT. For Revision 1 and 0, Integers are 32 bits. 5161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * For Revision 2 and above, Integers are 64 bits. Yes, this 5171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * makes a difference. 5181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 5191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 5201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5214be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownvoid acpi_ut_set_integer_width(u8 revision) 5221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 5231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 524f3d2e7865c816258c699ff965768e46b50d536d3Bob Moore if (revision < 2) { 525f6dd9221dddb3550e60d32aee688588ec208312cBob Moore 526f6dd9221dddb3550e60d32aee688588ec208312cBob Moore /* 32-bit case */ 527f6dd9221dddb3550e60d32aee688588ec208312cBob Moore 5281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds acpi_gbl_integer_bit_width = 32; 5291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds acpi_gbl_integer_nybble_width = 8; 5301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds acpi_gbl_integer_byte_width = 4; 5314be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown } else { 532f6dd9221dddb3550e60d32aee688588ec208312cBob Moore /* 64-bit case (ACPI 2.0+) */ 533f6dd9221dddb3550e60d32aee688588ec208312cBob Moore 5341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds acpi_gbl_integer_bit_width = 64; 5351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds acpi_gbl_integer_nybble_width = 16; 5361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds acpi_gbl_integer_byte_width = 8; 5371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 5391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef ACPI_DEBUG_OUTPUT 5411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 5421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 5431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_display_init_pathname 5441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 54544f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * PARAMETERS: Type - Object type of the node 54644f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * obj_handle - Handle whose pathname will be displayed 5471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Path - Additional path string to be appended. 5481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * (NULL if no extra path) 5491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 5501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: acpi_status 5511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 5521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Display full pathname of an object, DEBUG ONLY 5531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 5541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 5551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid 5574be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ut_display_init_pathname(u8 type, 5584be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown struct acpi_namespace_node *obj_handle, 5594be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown char *path) 5601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 5614be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status; 5624be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown struct acpi_buffer buffer; 5631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5644be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_ENTRY(); 5651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Only print the path if the appropriate debug level is enabled */ 5671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { 5691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return; 5701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Get the full pathname to the node */ 5731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 5754be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = acpi_ns_handle_to_pathname(obj_handle, &buffer); 5764be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 5771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return; 5781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Print what we're doing */ 5811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds switch (type) { 5831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case ACPI_TYPE_METHOD: 5844be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("Executing "); 5851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 5861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds default: 5884be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("Initializing "); 5891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 5901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 5911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Print the object type and pathname */ 5931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5944be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("%-12s %s", 5954be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_get_type_name(type), (char *)buffer.pointer); 5961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Extra path is used to append names like _STA, _INI, etc. */ 5981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 5991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (path) { 6004be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf(".%s", path); 6011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 6024be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_os_printf("\n"); 6031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6048313524a0d466f451a62709aaedf988d8257b21cBob Moore ACPI_FREE(buffer.pointer); 6051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 6061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 6071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 6091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 610793c2388cae3fd023b3b5166354931752d42353cBob Moore * FUNCTION: acpi_ut_valid_acpi_char 611793c2388cae3fd023b3b5166354931752d42353cBob Moore * 612793c2388cae3fd023b3b5166354931752d42353cBob Moore * PARAMETERS: Char - The character to be examined 613f6dd9221dddb3550e60d32aee688588ec208312cBob Moore * Position - Byte position (0-3) 614793c2388cae3fd023b3b5166354931752d42353cBob Moore * 615793c2388cae3fd023b3b5166354931752d42353cBob Moore * RETURN: TRUE if the character is valid, FALSE otherwise 616793c2388cae3fd023b3b5166354931752d42353cBob Moore * 617793c2388cae3fd023b3b5166354931752d42353cBob Moore * DESCRIPTION: Check for a valid ACPI character. Must be one of: 618793c2388cae3fd023b3b5166354931752d42353cBob Moore * 1) Upper case alpha 619793c2388cae3fd023b3b5166354931752d42353cBob Moore * 2) numeric 620793c2388cae3fd023b3b5166354931752d42353cBob Moore * 3) underscore 621793c2388cae3fd023b3b5166354931752d42353cBob Moore * 622793c2388cae3fd023b3b5166354931752d42353cBob Moore * We allow a '!' as the last character because of the ASF! table 623793c2388cae3fd023b3b5166354931752d42353cBob Moore * 624793c2388cae3fd023b3b5166354931752d42353cBob Moore ******************************************************************************/ 625793c2388cae3fd023b3b5166354931752d42353cBob Moore 62667a119f990063f5662574f6d6414fe9bc5ece86aBob Mooreu8 acpi_ut_valid_acpi_char(char character, u32 position) 627793c2388cae3fd023b3b5166354931752d42353cBob Moore{ 628793c2388cae3fd023b3b5166354931752d42353cBob Moore 629793c2388cae3fd023b3b5166354931752d42353cBob Moore if (!((character >= 'A' && character <= 'Z') || 630793c2388cae3fd023b3b5166354931752d42353cBob Moore (character >= '0' && character <= '9') || (character == '_'))) { 631793c2388cae3fd023b3b5166354931752d42353cBob Moore 632793c2388cae3fd023b3b5166354931752d42353cBob Moore /* Allow a '!' in the last position */ 633793c2388cae3fd023b3b5166354931752d42353cBob Moore 634793c2388cae3fd023b3b5166354931752d42353cBob Moore if (character == '!' && position == 3) { 635793c2388cae3fd023b3b5166354931752d42353cBob Moore return (TRUE); 636793c2388cae3fd023b3b5166354931752d42353cBob Moore } 637793c2388cae3fd023b3b5166354931752d42353cBob Moore 638793c2388cae3fd023b3b5166354931752d42353cBob Moore return (FALSE); 639793c2388cae3fd023b3b5166354931752d42353cBob Moore } 640793c2388cae3fd023b3b5166354931752d42353cBob Moore 641793c2388cae3fd023b3b5166354931752d42353cBob Moore return (TRUE); 642793c2388cae3fd023b3b5166354931752d42353cBob Moore} 643793c2388cae3fd023b3b5166354931752d42353cBob Moore 644793c2388cae3fd023b3b5166354931752d42353cBob Moore/******************************************************************************* 645793c2388cae3fd023b3b5166354931752d42353cBob Moore * 6461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_valid_acpi_name 6471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 64844f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * PARAMETERS: Name - The name to be examined 6491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 65044f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * RETURN: TRUE if the name is valid, FALSE otherwise 6511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 6521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: 6531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1) Upper case alpha 6541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2) numeric 6551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3) underscore 6561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 6571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 6581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6594be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownu8 acpi_ut_valid_acpi_name(u32 name) 6601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 66167a119f990063f5662574f6d6414fe9bc5ece86aBob Moore u32 i; 6621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6634be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_ENTRY(); 6641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds for (i = 0; i < ACPI_NAME_SIZE; i++) { 666793c2388cae3fd023b3b5166354931752d42353cBob Moore if (!acpi_ut_valid_acpi_char 667793c2388cae3fd023b3b5166354931752d42353cBob Moore ((ACPI_CAST_PTR(char, &name))[i], i)) { 6681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (FALSE); 6691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 6701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 6711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (TRUE); 6731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 6741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 6761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 677793c2388cae3fd023b3b5166354931752d42353cBob Moore * FUNCTION: acpi_ut_repair_name 6781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 679793c2388cae3fd023b3b5166354931752d42353cBob Moore * PARAMETERS: Name - The ACPI name to be repaired 6801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 681793c2388cae3fd023b3b5166354931752d42353cBob Moore * RETURN: Repaired version of the name 6821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 683793c2388cae3fd023b3b5166354931752d42353cBob Moore * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and 684793c2388cae3fd023b3b5166354931752d42353cBob Moore * return the new name. 6851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 6861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 6871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 6883d81b236a82a26fa8bdef9096829675d81890dc9Bob Mooreacpi_name acpi_ut_repair_name(char *name) 6891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 69067a119f990063f5662574f6d6414fe9bc5ece86aBob Moore u32 i; 6913d81b236a82a26fa8bdef9096829675d81890dc9Bob Moore char new_name[ACPI_NAME_SIZE]; 6921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 693793c2388cae3fd023b3b5166354931752d42353cBob Moore for (i = 0; i < ACPI_NAME_SIZE; i++) { 6943d81b236a82a26fa8bdef9096829675d81890dc9Bob Moore new_name[i] = name[i]; 695793c2388cae3fd023b3b5166354931752d42353cBob Moore 696793c2388cae3fd023b3b5166354931752d42353cBob Moore /* 697793c2388cae3fd023b3b5166354931752d42353cBob Moore * Replace a bad character with something printable, yet technically 698793c2388cae3fd023b3b5166354931752d42353cBob Moore * still invalid. This prevents any collisions with existing "good" 699793c2388cae3fd023b3b5166354931752d42353cBob Moore * names in the namespace. 700793c2388cae3fd023b3b5166354931752d42353cBob Moore */ 7013d81b236a82a26fa8bdef9096829675d81890dc9Bob Moore if (!acpi_ut_valid_acpi_char(name[i], i)) { 702793c2388cae3fd023b3b5166354931752d42353cBob Moore new_name[i] = '*'; 703793c2388cae3fd023b3b5166354931752d42353cBob Moore } 704793c2388cae3fd023b3b5166354931752d42353cBob Moore } 7051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7063d81b236a82a26fa8bdef9096829675d81890dc9Bob Moore return (*(u32 *) new_name); 7071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 7081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 7101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 7111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_strtoul64 7121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 7131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: String - Null terminated string 7144119532c95547821dbe72d6916dfa1b2148475b3Bob Moore * Base - Radix of the string: 16 or ACPI_ANY_BASE; 7154119532c95547821dbe72d6916dfa1b2148475b3Bob Moore * ACPI_ANY_BASE means 'in behalf of to_integer' 7161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * ret_integer - Where the converted integer is returned 7171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 7181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status and Converted value 7191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 720f6dd9221dddb3550e60d32aee688588ec208312cBob Moore * DESCRIPTION: Convert a string into an unsigned value. Performs either a 721f6dd9221dddb3550e60d32aee688588ec208312cBob Moore * 32-bit or 64-bit conversion, depending on the current mode 722f6dd9221dddb3550e60d32aee688588ec208312cBob Moore * of the interpreter. 7231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * NOTE: Does not support Octal strings, not needed. 7241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 7251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 7261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7275df7e6cb42da36c7d878239bebc81907b15f3943Bob Mooreacpi_status acpi_ut_strtoul64(char *string, u32 base, u64 * ret_integer) 7281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 7294be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 this_digit = 0; 7305df7e6cb42da36c7d878239bebc81907b15f3943Bob Moore u64 return_value = 0; 7315df7e6cb42da36c7d878239bebc81907b15f3943Bob Moore u64 quotient; 7325df7e6cb42da36c7d878239bebc81907b15f3943Bob Moore u64 dividend; 7334119532c95547821dbe72d6916dfa1b2148475b3Bob Moore u32 to_integer_op = (base == ACPI_ANY_BASE); 7344119532c95547821dbe72d6916dfa1b2148475b3Bob Moore u32 mode32 = (acpi_gbl_integer_byte_width == 4); 7354119532c95547821dbe72d6916dfa1b2148475b3Bob Moore u8 valid_digits = 0; 7364119532c95547821dbe72d6916dfa1b2148475b3Bob Moore u8 sign_of0x = 0; 7374119532c95547821dbe72d6916dfa1b2148475b3Bob Moore u8 term = 0; 7381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 739f6dd9221dddb3550e60d32aee688588ec208312cBob Moore ACPI_FUNCTION_TRACE_STR(ut_stroul64, string); 7401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds switch (base) { 7421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case ACPI_ANY_BASE: 7431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds case 16: 7441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 7451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds default: 7471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Invalid Base */ 7484be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_BAD_PARAMETER); 7491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 7501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7514119532c95547821dbe72d6916dfa1b2148475b3Bob Moore if (!string) { 7524119532c95547821dbe72d6916dfa1b2148475b3Bob Moore goto error_exit; 7534119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } 7544119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 7551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Skip over any white space in the buffer */ 7561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7574119532c95547821dbe72d6916dfa1b2148475b3Bob Moore while ((*string) && (ACPI_IS_SPACE(*string) || *string == '\t')) { 7581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds string++; 7591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 7601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7614119532c95547821dbe72d6916dfa1b2148475b3Bob Moore if (to_integer_op) { 7624119532c95547821dbe72d6916dfa1b2148475b3Bob Moore /* 7634119532c95547821dbe72d6916dfa1b2148475b3Bob Moore * Base equal to ACPI_ANY_BASE means 'to_integer operation case'. 7644119532c95547821dbe72d6916dfa1b2148475b3Bob Moore * We need to determine if it is decimal or hexadecimal. 7654119532c95547821dbe72d6916dfa1b2148475b3Bob Moore */ 7664be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if ((*string == '0') && (ACPI_TOLOWER(*(string + 1)) == 'x')) { 7674119532c95547821dbe72d6916dfa1b2148475b3Bob Moore sign_of0x = 1; 7681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds base = 16; 7694119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 7704119532c95547821dbe72d6916dfa1b2148475b3Bob Moore /* Skip over the leading '0x' */ 7711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds string += 2; 7724be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown } else { 7731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds base = 10; 7741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 7751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 7761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7774119532c95547821dbe72d6916dfa1b2148475b3Bob Moore /* Any string left? Check that '0x' is not followed by white space. */ 7784119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 7794119532c95547821dbe72d6916dfa1b2148475b3Bob Moore if (!(*string) || ACPI_IS_SPACE(*string) || *string == '\t') { 7804119532c95547821dbe72d6916dfa1b2148475b3Bob Moore if (to_integer_op) { 7814119532c95547821dbe72d6916dfa1b2148475b3Bob Moore goto error_exit; 7824119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } else { 7834119532c95547821dbe72d6916dfa1b2148475b3Bob Moore goto all_done; 7844119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } 7851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 7861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 787f6dd9221dddb3550e60d32aee688588ec208312cBob Moore /* 788f6dd9221dddb3550e60d32aee688588ec208312cBob Moore * Perform a 32-bit or 64-bit conversion, depending upon the current 789f6dd9221dddb3550e60d32aee688588ec208312cBob Moore * execution mode of the interpreter 790f6dd9221dddb3550e60d32aee688588ec208312cBob Moore */ 7914119532c95547821dbe72d6916dfa1b2148475b3Bob Moore dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; 7921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 793f6dd9221dddb3550e60d32aee688588ec208312cBob Moore /* Main loop: convert the string to a 32- or 64-bit integer */ 7941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 7951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds while (*string) { 7964be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_IS_DIGIT(*string)) { 79752fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 7981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Convert ASCII 0-9 to Decimal value */ 7991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8004be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown this_digit = ((u8) * string) - '0'; 8014119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } else if (base == 10) { 8021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8034119532c95547821dbe72d6916dfa1b2148475b3Bob Moore /* Digit is out of range; possible in to_integer case only */ 8041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8054119532c95547821dbe72d6916dfa1b2148475b3Bob Moore term = 1; 8064119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } else { 8074be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown this_digit = (u8) ACPI_TOUPPER(*string); 8084be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_IS_XDIGIT((char)this_digit)) { 80952fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 8101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Convert ASCII Hex char to value */ 8111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds this_digit = this_digit - 'A' + 10; 8134be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown } else { 8144119532c95547821dbe72d6916dfa1b2148475b3Bob Moore term = 1; 8154119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } 8164119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } 8174119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 8184119532c95547821dbe72d6916dfa1b2148475b3Bob Moore if (term) { 8194119532c95547821dbe72d6916dfa1b2148475b3Bob Moore if (to_integer_op) { 8204119532c95547821dbe72d6916dfa1b2148475b3Bob Moore goto error_exit; 8214119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } else { 8221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds break; 8231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 8244119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } else if ((valid_digits == 0) && (this_digit == 0) 8254119532c95547821dbe72d6916dfa1b2148475b3Bob Moore && !sign_of0x) { 8264119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 8274119532c95547821dbe72d6916dfa1b2148475b3Bob Moore /* Skip zeros */ 8284119532c95547821dbe72d6916dfa1b2148475b3Bob Moore string++; 8294119532c95547821dbe72d6916dfa1b2148475b3Bob Moore continue; 8304119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } 8314119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 8324119532c95547821dbe72d6916dfa1b2148475b3Bob Moore valid_digits++; 8334119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 834fd3509436fde38d4c854bf5a6b83d2c779904f8eLen Brown if (sign_of0x && ((valid_digits > 16) 835fd3509436fde38d4c854bf5a6b83d2c779904f8eLen Brown || ((valid_digits > 8) && mode32))) { 8364119532c95547821dbe72d6916dfa1b2148475b3Bob Moore /* 8374119532c95547821dbe72d6916dfa1b2148475b3Bob Moore * This is to_integer operation case. 8384119532c95547821dbe72d6916dfa1b2148475b3Bob Moore * No any restrictions for string-to-integer conversion, 8394119532c95547821dbe72d6916dfa1b2148475b3Bob Moore * see ACPI spec. 8404119532c95547821dbe72d6916dfa1b2148475b3Bob Moore */ 8414119532c95547821dbe72d6916dfa1b2148475b3Bob Moore goto error_exit; 8421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 8431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Divide the digit into the correct position */ 8451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8465df7e6cb42da36c7d878239bebc81907b15f3943Bob Moore (void)acpi_ut_short_divide((dividend - (u64) this_digit), 8475df7e6cb42da36c7d878239bebc81907b15f3943Bob Moore base, "ient, NULL); 8484119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 8491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (return_value > quotient) { 8504119532c95547821dbe72d6916dfa1b2148475b3Bob Moore if (to_integer_op) { 8514119532c95547821dbe72d6916dfa1b2148475b3Bob Moore goto error_exit; 8524119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } else { 8534119532c95547821dbe72d6916dfa1b2148475b3Bob Moore break; 8544119532c95547821dbe72d6916dfa1b2148475b3Bob Moore } 8551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 8561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return_value *= base; 8581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return_value += this_digit; 8591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds string++; 8601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 8611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* All done, normal exit */ 8631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8644119532c95547821dbe72d6916dfa1b2148475b3Bob Moore all_done: 8654119532c95547821dbe72d6916dfa1b2148475b3Bob Moore 866f6dd9221dddb3550e60d32aee688588ec208312cBob Moore ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", 867f6dd9221dddb3550e60d32aee688588ec208312cBob Moore ACPI_FORMAT_UINT64(return_value))); 868f6dd9221dddb3550e60d32aee688588ec208312cBob Moore 8691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *ret_integer = return_value; 8704be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 8711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8724be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown error_exit: 8731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Base was set/validated above */ 8741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (base == 10) { 8764be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT); 8774be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown } else { 8784be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_BAD_HEX_CONSTANT); 8791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 8801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 8811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 8831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 8841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_create_update_state_and_push 8851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 88644f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * PARAMETERS: Object - Object to be added to the new state 8871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Action - Increment/Decrement 8881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * state_list - List the state will be added to 8891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 89044f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * RETURN: Status 8911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 8921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Create a new state and push it 8931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 8941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 8951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 8961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 8974be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ut_create_update_state_and_push(union acpi_operand_object *object, 8984be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u16 action, 8994be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_generic_state **state_list) 9001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 9014be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_generic_state *state; 9021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9034be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_FUNCTION_ENTRY(); 9041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Ignore null objects; these are expected */ 9061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!object) { 9081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (AE_OK); 9091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 9101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9114be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown state = acpi_ut_create_update_state(object, action); 9121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!state) { 9131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (AE_NO_MEMORY); 9141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 9151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9164be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_push_generic_state(state_list, state); 9171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return (AE_OK); 9181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 9191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 9211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 9221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * FUNCTION: acpi_ut_walk_package_tree 9231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 92444f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * PARAMETERS: source_object - The package to walk 92544f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * target_object - Target object (if package is being copied) 92644f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * walk_callback - Called once for each package element 92744f6c01242da4e162f28d8e1216a8c7a91174605Robert Moore * Context - Passed to the callback function 9281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 9291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: Status 9301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 9311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * DESCRIPTION: Walk through a package 9321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 9331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 9341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsacpi_status 9364be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brownacpi_ut_walk_package_tree(union acpi_operand_object * source_object, 9374be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown void *target_object, 9384be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_pkg_callback walk_callback, void *context) 9391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 9404be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_status status = AE_OK; 9414be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_generic_state *state_list = NULL; 9424be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_generic_state *state; 9434be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown u32 this_index; 9444be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown union acpi_operand_object *this_source_obj; 9451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 946b229cf92eee616c7cb5ad8cdb35a19b119f00bc8Bob Moore ACPI_FUNCTION_TRACE(ut_walk_package_tree); 9471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9484be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown state = acpi_ut_create_pkg_state(source_object, target_object, 0); 9491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!state) { 9504be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_NO_MEMORY); 9511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 9521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds while (state) { 95452fc0b026e99b5d5d585095148d997d5634bbc25Bob Moore 9551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Get one element of the package */ 9561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9574be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown this_index = state->pkg.index; 9581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds this_source_obj = (union acpi_operand_object *) 9594be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown state->pkg.source_object->package.elements[this_index]; 9601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 9621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Check for: 9631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1) An uninitialized package element. It is completely 9641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * legal to declare a package and leave it uninitialized 9651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2) Not an internal object - can be a namespace node instead 9661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 3) Any type other than a package. Packages are handled in else 9671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * case below. 9681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 9691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if ((!this_source_obj) || 9704be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown (ACPI_GET_DESCRIPTOR_TYPE(this_source_obj) != 9714be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown ACPI_DESC_TYPE_OPERAND) 9723371c19c294a4cb3649aa4e84606be8a1d999e61Bob Moore || (this_source_obj->common.type != ACPI_TYPE_PACKAGE)) { 9734be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 9744be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown walk_callback(ACPI_COPY_TYPE_SIMPLE, 9754be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown this_source_obj, state, context); 9764be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 9774be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(status); 9781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 9791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds state->pkg.index++; 9814be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown while (state->pkg.index >= 9824be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown state->pkg.source_object->package.count) { 9831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 9841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * We've handled all of the objects at this level, This means 9851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * that we have just completed a package. That package may 9861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * have contained one or more packages itself. 9871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 9881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Delete this state and pop the previous state (package). 9891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 9904be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_delete_generic_state(state); 9914be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown state = acpi_ut_pop_generic_state(&state_list); 9921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Finished when there are no more states */ 9941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 9951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!state) { 9961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 9971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * We have handled all of the objects in the top level 9981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * package just add the length of the package objects 9991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * and exit 10001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 10014be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_OK); 10021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 10031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 10051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Go back up a level and move the index past the just 10061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * completed package object. 10071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 10081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds state->pkg.index++; 10091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 10104be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown } else { 10111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* This is a subobject of type package */ 10121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10134be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown status = 10144be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown walk_callback(ACPI_COPY_TYPE_PACKAGE, 10154be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown this_source_obj, state, context); 10164be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown if (ACPI_FAILURE(status)) { 10174be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(status); 10181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 10191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 10211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Push the current state and create a new one 10221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * The callback above returned a new target package object. 10231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 10244be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown acpi_ut_push_generic_state(&state_list, state); 10254be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown state = acpi_ut_create_pkg_state(this_source_obj, 10264be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown state->pkg. 10274be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown this_target_obj, 0); 10281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!state) { 1029cf058bd1c84df9921ecc517d8a8a413f4d6b5b45Lin Ming 1030cf058bd1c84df9921ecc517d8a8a413f4d6b5b45Lin Ming /* Free any stacked Update State objects */ 1031cf058bd1c84df9921ecc517d8a8a413f4d6b5b45Lin Ming 1032cf058bd1c84df9921ecc517d8a8a413f4d6b5b45Lin Ming while (state_list) { 1033cf058bd1c84df9921ecc517d8a8a413f4d6b5b45Lin Ming state = 1034cf058bd1c84df9921ecc517d8a8a413f4d6b5b45Lin Ming acpi_ut_pop_generic_state 1035cf058bd1c84df9921ecc517d8a8a413f4d6b5b45Lin Ming (&state_list); 1036cf058bd1c84df9921ecc517d8a8a413f4d6b5b45Lin Ming acpi_ut_delete_generic_state(state); 1037cf058bd1c84df9921ecc517d8a8a413f4d6b5b45Lin Ming } 10384be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_NO_MEMORY); 10391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 10401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 10411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 10421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* We should never get here */ 10441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10454be44fcd3bf648b782f4460fd06dfae6c42ded4bLen Brown return_ACPI_STATUS(AE_AML_INTERNAL); 10461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 10471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 10481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/******************************************************************************* 10491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 105050df4d8b0f6e1971b930f3158c9ee0e4263e636dBob Moore * FUNCTION: acpi_error, acpi_exception, acpi_warning, acpi_info 10511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 10521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * PARAMETERS: module_name - Caller's module name (for error output) 10531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * line_number - Caller's line number (for error output) 1054b8e4d89357fc434618a59c1047cac72641191805Bob Moore * Format - Printf format string + additional args 10551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 10561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * RETURN: None 10571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 1058b8e4d89357fc434618a59c1047cac72641191805Bob Moore * DESCRIPTION: Print message with module/line/version info 10591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 10601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds ******************************************************************************/ 10611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1062b8e4d89357fc434618a59c1047cac72641191805Bob Moorevoid ACPI_INTERNAL_VAR_XFACE 106350df4d8b0f6e1971b930f3158c9ee0e4263e636dBob Mooreacpi_error(const char *module_name, u32 line_number, const char *format, ...) 10641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1065b8e4d89357fc434618a59c1047cac72641191805Bob Moore va_list args; 10661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1067b74be6119e9e38390395f08767b7c84de9023b38Bob Moore acpi_os_printf("ACPI Error: "); 1068b8e4d89357fc434618a59c1047cac72641191805Bob Moore 1069b8e4d89357fc434618a59c1047cac72641191805Bob Moore va_start(args, format); 1070b8e4d89357fc434618a59c1047cac72641191805Bob Moore acpi_os_vprintf(format, args); 10710444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore ACPI_COMMON_MSG_SUFFIX; 1072507f046c4dd17e9c94b5130ba184f8da90504685Bob Moore va_end(args); 10731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 10741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1075b8e4d89357fc434618a59c1047cac72641191805Bob Moorevoid ACPI_INTERNAL_VAR_XFACE 107650df4d8b0f6e1971b930f3158c9ee0e4263e636dBob Mooreacpi_exception(const char *module_name, 107750df4d8b0f6e1971b930f3158c9ee0e4263e636dBob Moore u32 line_number, acpi_status status, const char *format, ...) 1078b8e4d89357fc434618a59c1047cac72641191805Bob Moore{ 1079b8e4d89357fc434618a59c1047cac72641191805Bob Moore va_list args; 10801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1081b74be6119e9e38390395f08767b7c84de9023b38Bob Moore acpi_os_printf("ACPI Exception: %s, ", acpi_format_exception(status)); 1082b8e4d89357fc434618a59c1047cac72641191805Bob Moore 1083b8e4d89357fc434618a59c1047cac72641191805Bob Moore va_start(args, format); 1084b8e4d89357fc434618a59c1047cac72641191805Bob Moore acpi_os_vprintf(format, args); 10850444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore ACPI_COMMON_MSG_SUFFIX; 10863549dba2c334e82df90f5e00ff85d2a7a2cdd1afLen Brown va_end(args); 1087b8e4d89357fc434618a59c1047cac72641191805Bob Moore} 1088fd3509436fde38d4c854bf5a6b83d2c779904f8eLen Brown 1089b8e4d89357fc434618a59c1047cac72641191805Bob Moorevoid ACPI_INTERNAL_VAR_XFACE 109050df4d8b0f6e1971b930f3158c9ee0e4263e636dBob Mooreacpi_warning(const char *module_name, u32 line_number, const char *format, ...) 10911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1092b8e4d89357fc434618a59c1047cac72641191805Bob Moore va_list args; 10931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1094b74be6119e9e38390395f08767b7c84de9023b38Bob Moore acpi_os_printf("ACPI Warning: "); 1095b8e4d89357fc434618a59c1047cac72641191805Bob Moore 1096b8e4d89357fc434618a59c1047cac72641191805Bob Moore va_start(args, format); 1097b8e4d89357fc434618a59c1047cac72641191805Bob Moore acpi_os_vprintf(format, args); 10980444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore ACPI_COMMON_MSG_SUFFIX; 1099507f046c4dd17e9c94b5130ba184f8da90504685Bob Moore va_end(args); 1100b8e4d89357fc434618a59c1047cac72641191805Bob Moore} 1101cece92969762b8ed7930d4e23008b76b06411deeLen Brown 1102b8e4d89357fc434618a59c1047cac72641191805Bob Moorevoid ACPI_INTERNAL_VAR_XFACE 110350df4d8b0f6e1971b930f3158c9ee0e4263e636dBob Mooreacpi_info(const char *module_name, u32 line_number, const char *format, ...) 1104b8e4d89357fc434618a59c1047cac72641191805Bob Moore{ 1105b8e4d89357fc434618a59c1047cac72641191805Bob Moore va_list args; 1106b8e4d89357fc434618a59c1047cac72641191805Bob Moore 1107c5fc42ac4d4d6d3e3f619290b86890cb3725d2f8Bob Moore acpi_os_printf("ACPI: "); 1108b8e4d89357fc434618a59c1047cac72641191805Bob Moore 1109b8e4d89357fc434618a59c1047cac72641191805Bob Moore va_start(args, format); 1110b8e4d89357fc434618a59c1047cac72641191805Bob Moore acpi_os_vprintf(format, args); 1111c5fc42ac4d4d6d3e3f619290b86890cb3725d2f8Bob Moore acpi_os_printf("\n"); 1112507f046c4dd17e9c94b5130ba184f8da90504685Bob Moore va_end(args); 11131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 111450df4d8b0f6e1971b930f3158c9ee0e4263e636dBob Moore 111550df4d8b0f6e1971b930f3158c9ee0e4263e636dBob MooreACPI_EXPORT_SYMBOL(acpi_error) 111650df4d8b0f6e1971b930f3158c9ee0e4263e636dBob MooreACPI_EXPORT_SYMBOL(acpi_exception) 111750df4d8b0f6e1971b930f3158c9ee0e4263e636dBob MooreACPI_EXPORT_SYMBOL(acpi_warning) 111850df4d8b0f6e1971b930f3158c9ee0e4263e636dBob MooreACPI_EXPORT_SYMBOL(acpi_info) 11190444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore 11200444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore/******************************************************************************* 11210444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * 11220444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * FUNCTION: acpi_ut_predefined_warning 11230444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * 11240444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * PARAMETERS: module_name - Caller's module name (for error output) 11250444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * line_number - Caller's line number (for error output) 11260444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * Pathname - Full pathname to the node 11270444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * node_flags - From Namespace node for the method/object 11280444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * Format - Printf format string + additional args 11290444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * 11300444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * RETURN: None 11310444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * 11320444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * DESCRIPTION: Warnings for the predefined validation module. Messages are 11330444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * only emitted the first time a problem with a particular 11340444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * method/object is detected. This prevents a flood of error 11350444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * messages for methods that are repeatedly evaluated. 11360444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * 11370444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore******************************************************************************/ 11380444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore 11390444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moorevoid ACPI_INTERNAL_VAR_XFACE 11400444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Mooreacpi_ut_predefined_warning(const char *module_name, 11410444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore u32 line_number, 11420444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore char *pathname, 11430444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore u8 node_flags, const char *format, ...) 11440444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore{ 11450444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore va_list args; 11460444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore 11470444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore /* 11480444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * Warning messages for this method/object will be disabled after the 11490444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore * first time a validation fails or an object is successfully repaired. 11500444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore */ 11510444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore if (node_flags & ANOBJ_EVALUATED) { 11520444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore return; 11530444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore } 11540444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore 11550444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore acpi_os_printf("ACPI Warning for %s: ", pathname); 11560444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore 11570444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore va_start(args, format); 11580444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore acpi_os_vprintf(format, args); 11590444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore ACPI_COMMON_MSG_SUFFIX; 11600444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore va_end(args); 11610444e8f6d72d6e38f92d48884bc90bbc6c22fd5aBob Moore} 11627df200cd980442868f5579c0880a9221da628d17Bob Moore 11637df200cd980442868f5579c0880a9221da628d17Bob Moore/******************************************************************************* 11647df200cd980442868f5579c0880a9221da628d17Bob Moore * 11657df200cd980442868f5579c0880a9221da628d17Bob Moore * FUNCTION: acpi_ut_predefined_info 11667df200cd980442868f5579c0880a9221da628d17Bob Moore * 11677df200cd980442868f5579c0880a9221da628d17Bob Moore * PARAMETERS: module_name - Caller's module name (for error output) 11687df200cd980442868f5579c0880a9221da628d17Bob Moore * line_number - Caller's line number (for error output) 11697df200cd980442868f5579c0880a9221da628d17Bob Moore * Pathname - Full pathname to the node 11707df200cd980442868f5579c0880a9221da628d17Bob Moore * node_flags - From Namespace node for the method/object 11717df200cd980442868f5579c0880a9221da628d17Bob Moore * Format - Printf format string + additional args 11727df200cd980442868f5579c0880a9221da628d17Bob Moore * 11737df200cd980442868f5579c0880a9221da628d17Bob Moore * RETURN: None 11747df200cd980442868f5579c0880a9221da628d17Bob Moore * 11757df200cd980442868f5579c0880a9221da628d17Bob Moore * DESCRIPTION: Info messages for the predefined validation module. Messages 11767df200cd980442868f5579c0880a9221da628d17Bob Moore * are only emitted the first time a problem with a particular 11777df200cd980442868f5579c0880a9221da628d17Bob Moore * method/object is detected. This prevents a flood of 11787df200cd980442868f5579c0880a9221da628d17Bob Moore * messages for methods that are repeatedly evaluated. 11797df200cd980442868f5579c0880a9221da628d17Bob Moore * 11807df200cd980442868f5579c0880a9221da628d17Bob Moore ******************************************************************************/ 11817df200cd980442868f5579c0880a9221da628d17Bob Moore 11827df200cd980442868f5579c0880a9221da628d17Bob Moorevoid ACPI_INTERNAL_VAR_XFACE 11837df200cd980442868f5579c0880a9221da628d17Bob Mooreacpi_ut_predefined_info(const char *module_name, 11847df200cd980442868f5579c0880a9221da628d17Bob Moore u32 line_number, 11857df200cd980442868f5579c0880a9221da628d17Bob Moore char *pathname, u8 node_flags, const char *format, ...) 11867df200cd980442868f5579c0880a9221da628d17Bob Moore{ 11877df200cd980442868f5579c0880a9221da628d17Bob Moore va_list args; 11887df200cd980442868f5579c0880a9221da628d17Bob Moore 11897df200cd980442868f5579c0880a9221da628d17Bob Moore /* 11907df200cd980442868f5579c0880a9221da628d17Bob Moore * Warning messages for this method/object will be disabled after the 11917df200cd980442868f5579c0880a9221da628d17Bob Moore * first time a validation fails or an object is successfully repaired. 11927df200cd980442868f5579c0880a9221da628d17Bob Moore */ 11937df200cd980442868f5579c0880a9221da628d17Bob Moore if (node_flags & ANOBJ_EVALUATED) { 11947df200cd980442868f5579c0880a9221da628d17Bob Moore return; 11957df200cd980442868f5579c0880a9221da628d17Bob Moore } 11967df200cd980442868f5579c0880a9221da628d17Bob Moore 11977df200cd980442868f5579c0880a9221da628d17Bob Moore acpi_os_printf("ACPI Info for %s: ", pathname); 11987df200cd980442868f5579c0880a9221da628d17Bob Moore 11997df200cd980442868f5579c0880a9221da628d17Bob Moore va_start(args, format); 12007df200cd980442868f5579c0880a9221da628d17Bob Moore acpi_os_vprintf(format, args); 12017df200cd980442868f5579c0880a9221da628d17Bob Moore ACPI_COMMON_MSG_SUFFIX; 12027df200cd980442868f5579c0880a9221da628d17Bob Moore va_end(args); 12037df200cd980442868f5579c0880a9221da628d17Bob Moore} 1204