![]() |
|
|||
File indexing completed on 2025-05-11 08:24:03
0001 /****************************************************************************** 0002 * 0003 * Module Name: tbxface - ACPI table-oriented external interfaces 0004 * 0005 *****************************************************************************/ 0006 0007 /****************************************************************************** 0008 * 0009 * 1. Copyright Notice 0010 * 0011 * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp. 0012 * All rights reserved. 0013 * 0014 * 2. License 0015 * 0016 * 2.1. This is your license from Intel Corp. under its intellectual property 0017 * rights. You may have additional license terms from the party that provided 0018 * you this software, covering your right to use that party's intellectual 0019 * property rights. 0020 * 0021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0022 * copy of the source code appearing in this file ("Covered Code") an 0023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0024 * base code distributed originally by Intel ("Original Intel Code") to copy, 0025 * make derivatives, distribute, use and display any portion of the Covered 0026 * Code in any form, with the right to sublicense such rights; and 0027 * 0028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0029 * license (with the right to sublicense), under only those claims of Intel 0030 * patents that are infringed by the Original Intel Code, to make, use, sell, 0031 * offer to sell, and import the Covered Code and derivative works thereof 0032 * solely to the minimum extent necessary to exercise the above copyright 0033 * license, and in no event shall the patent license extend to any additions 0034 * to or modifications of the Original Intel Code. No other license or right 0035 * is granted directly or by implication, estoppel or otherwise; 0036 * 0037 * The above copyright and patent license is granted only if the following 0038 * conditions are met: 0039 * 0040 * 3. Conditions 0041 * 0042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0043 * Redistribution of source code of any substantial portion of the Covered 0044 * Code or modification with rights to further distribute source must include 0045 * the above Copyright Notice, the above License, this list of Conditions, 0046 * and the following Disclaimer and Export Compliance provision. In addition, 0047 * Licensee must cause all Covered Code to which Licensee contributes to 0048 * contain a file documenting the changes Licensee made to create that Covered 0049 * Code and the date of any change. Licensee must include in that file the 0050 * documentation of any changes made by any predecessor Licensee. Licensee 0051 * must include a prominent statement that the modification is derived, 0052 * directly or indirectly, from Original Intel Code. 0053 * 0054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0055 * Redistribution of source code of any substantial portion of the Covered 0056 * Code or modification without rights to further distribute source must 0057 * include the following Disclaimer and Export Compliance provision in the 0058 * documentation and/or other materials provided with distribution. In 0059 * addition, Licensee may not authorize further sublicense of source of any 0060 * portion of the Covered Code, and must include terms to the effect that the 0061 * license from Licensee to its licensee is limited to the intellectual 0062 * property embodied in the software Licensee provides to its licensee, and 0063 * not to intellectual property embodied in modifications its licensee may 0064 * make. 0065 * 0066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0067 * substantial portion of the Covered Code or modification must reproduce the 0068 * above Copyright Notice, and the following Disclaimer and Export Compliance 0069 * provision in the documentation and/or other materials provided with the 0070 * distribution. 0071 * 0072 * 3.4. Intel retains all right, title, and interest in and to the Original 0073 * Intel Code. 0074 * 0075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0076 * Intel shall be used in advertising or otherwise to promote the sale, use or 0077 * other dealings in products derived from or relating to the Covered Code 0078 * without prior written authorization from Intel. 0079 * 0080 * 4. Disclaimer and Export Compliance 0081 * 0082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0088 * PARTICULAR PURPOSE. 0089 * 0090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0097 * LIMITED REMEDY. 0098 * 0099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0100 * software or system incorporating such software without first obtaining any 0101 * required license or other approval from the U. S. Department of Commerce or 0102 * any other agency or department of the United States Government. In the 0103 * event Licensee exports any such software from the United States or 0104 * re-exports any such software from a foreign destination, Licensee shall 0105 * ensure that the distribution and export/re-export of the software is in 0106 * compliance with all laws, regulations, orders, or other restrictions of the 0107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0108 * any of its subsidiaries will export/re-export any technical data, process, 0109 * software, or service, directly or indirectly, to any country for which the 0110 * United States government or any agency thereof requires an export license, 0111 * other governmental approval, or letter of assurance, without first obtaining 0112 * such license, approval or letter. 0113 * 0114 ***************************************************************************** 0115 * 0116 * Alternatively, you may choose to be licensed under the terms of the 0117 * following license: 0118 * 0119 * Redistribution and use in source and binary forms, with or without 0120 * modification, are permitted provided that the following conditions 0121 * are met: 0122 * 1. Redistributions of source code must retain the above copyright 0123 * notice, this list of conditions, and the following disclaimer, 0124 * without modification. 0125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 0126 * substantially similar to the "NO WARRANTY" disclaimer below 0127 * ("Disclaimer") and any redistribution must be conditioned upon 0128 * including a substantially similar Disclaimer requirement for further 0129 * binary redistribution. 0130 * 3. Neither the names of the above-listed copyright holders nor the names 0131 * of any contributors may be used to endorse or promote products derived 0132 * from this software without specific prior written permission. 0133 * 0134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0145 * 0146 * Alternatively, you may choose to be licensed under the terms of the 0147 * GNU General Public License ("GPL") version 2 as published by the Free 0148 * Software Foundation. 0149 * 0150 *****************************************************************************/ 0151 0152 #define EXPORT_ACPI_INTERFACES 0153 0154 #include "acpi.h" 0155 #include "accommon.h" 0156 #include "actables.h" 0157 0158 #define _COMPONENT ACPI_TABLES 0159 ACPI_MODULE_NAME ("tbxface") 0160 0161 0162 /******************************************************************************* 0163 * 0164 * FUNCTION: AcpiAllocateRootTable 0165 * 0166 * PARAMETERS: InitialTableCount - Size of InitialTableArray, in number of 0167 * ACPI_TABLE_DESC structures 0168 * 0169 * RETURN: Status 0170 * 0171 * DESCRIPTION: Allocate a root table array. Used by iASL compiler and 0172 * AcpiInitializeTables. 0173 * 0174 ******************************************************************************/ 0175 0176 ACPI_STATUS 0177 AcpiAllocateRootTable ( 0178 UINT32 InitialTableCount) 0179 { 0180 0181 AcpiGbl_RootTableList.MaxTableCount = InitialTableCount; 0182 AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE; 0183 0184 return (AcpiTbResizeRootTableList ()); 0185 } 0186 0187 0188 /******************************************************************************* 0189 * 0190 * FUNCTION: AcpiInitializeTables 0191 * 0192 * PARAMETERS: InitialTableArray - Pointer to an array of pre-allocated 0193 * ACPI_TABLE_DESC structures. If NULL, the 0194 * array is dynamically allocated. 0195 * InitialTableCount - Size of InitialTableArray, in number of 0196 * ACPI_TABLE_DESC structures 0197 * AllowResize - Flag to tell Table Manager if resize of 0198 * pre-allocated array is allowed. Ignored 0199 * if InitialTableArray is NULL. 0200 * 0201 * RETURN: Status 0202 * 0203 * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT. 0204 * 0205 * NOTE: Allows static allocation of the initial table array in order 0206 * to avoid the use of dynamic memory in confined environments 0207 * such as the kernel boot sequence where it may not be available. 0208 * 0209 * If the host OS memory managers are initialized, use NULL for 0210 * InitialTableArray, and the table will be dynamically allocated. 0211 * 0212 ******************************************************************************/ 0213 0214 ACPI_STATUS ACPI_INIT_FUNCTION 0215 AcpiInitializeTables ( 0216 ACPI_TABLE_DESC *InitialTableArray, 0217 UINT32 InitialTableCount, 0218 BOOLEAN AllowResize) 0219 { 0220 ACPI_PHYSICAL_ADDRESS RsdpAddress; 0221 ACPI_STATUS Status; 0222 0223 0224 ACPI_FUNCTION_TRACE (AcpiInitializeTables); 0225 0226 0227 /* 0228 * Setup the Root Table Array and allocate the table array 0229 * if requested 0230 */ 0231 if (!InitialTableArray) 0232 { 0233 Status = AcpiAllocateRootTable (InitialTableCount); 0234 if (ACPI_FAILURE (Status)) 0235 { 0236 return_ACPI_STATUS (Status); 0237 } 0238 } 0239 else 0240 { 0241 /* Root Table Array has been statically allocated by the host */ 0242 0243 memset (InitialTableArray, 0, 0244 (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC)); 0245 0246 AcpiGbl_RootTableList.Tables = InitialTableArray; 0247 AcpiGbl_RootTableList.MaxTableCount = InitialTableCount; 0248 AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN; 0249 if (AllowResize) 0250 { 0251 AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; 0252 } 0253 } 0254 0255 /* Get the address of the RSDP */ 0256 0257 RsdpAddress = AcpiOsGetRootPointer (); 0258 if (!RsdpAddress) 0259 { 0260 return_ACPI_STATUS (AE_NOT_FOUND); 0261 } 0262 0263 /* 0264 * Get the root table (RSDT or XSDT) and extract all entries to the local 0265 * Root Table Array. This array contains the information of the RSDT/XSDT 0266 * in a common, more usable format. 0267 */ 0268 Status = AcpiTbParseRootTable (RsdpAddress); 0269 return_ACPI_STATUS (Status); 0270 } 0271 0272 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeTables) 0273 0274 0275 /******************************************************************************* 0276 * 0277 * FUNCTION: AcpiReallocateRootTable 0278 * 0279 * PARAMETERS: None 0280 * 0281 * RETURN: Status 0282 * 0283 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the 0284 * root list from the previously provided scratch area. Should 0285 * be called once dynamic memory allocation is available in the 0286 * kernel. 0287 * 0288 ******************************************************************************/ 0289 0290 ACPI_STATUS ACPI_INIT_FUNCTION 0291 AcpiReallocateRootTable ( 0292 void) 0293 { 0294 ACPI_STATUS Status; 0295 ACPI_TABLE_DESC *TableDesc; 0296 UINT32 i, j; 0297 0298 0299 ACPI_FUNCTION_TRACE (AcpiReallocateRootTable); 0300 0301 0302 /* 0303 * If there are tables unverified, it is required to reallocate the 0304 * root table list to clean up invalid table entries. Otherwise only 0305 * reallocate the root table list if the host provided a static buffer 0306 * for the table array in the call to AcpiInitializeTables(). 0307 */ 0308 if ((AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) && 0309 AcpiGbl_EnableTableValidation) 0310 { 0311 return_ACPI_STATUS (AE_SUPPORT); 0312 } 0313 0314 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 0315 0316 /* 0317 * Ensure OS early boot logic, which is required by some hosts. If the 0318 * table state is reported to be wrong, developers should fix the 0319 * issue by invoking AcpiPutTable() for the reported table during the 0320 * early stage. 0321 */ 0322 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) 0323 { 0324 TableDesc = &AcpiGbl_RootTableList.Tables[i]; 0325 if (TableDesc->Pointer) 0326 { 0327 ACPI_ERROR ((AE_INFO, 0328 "Table [%4.4s] is not invalidated during early boot stage", 0329 TableDesc->Signature.Ascii)); 0330 } 0331 } 0332 0333 if (!AcpiGbl_EnableTableValidation) 0334 { 0335 /* 0336 * Now it's safe to do full table validation. We can do deferred 0337 * table initialization here once the flag is set. 0338 */ 0339 AcpiGbl_EnableTableValidation = TRUE; 0340 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i) 0341 { 0342 TableDesc = &AcpiGbl_RootTableList.Tables[i]; 0343 if (!(TableDesc->Flags & ACPI_TABLE_IS_VERIFIED)) 0344 { 0345 Status = AcpiTbVerifyTempTable (TableDesc, NULL, &j); 0346 if (ACPI_FAILURE (Status)) 0347 { 0348 AcpiTbUninstallTable (TableDesc); 0349 } 0350 } 0351 } 0352 } 0353 0354 AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; 0355 Status = AcpiTbResizeRootTableList (); 0356 AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED; 0357 0358 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 0359 return_ACPI_STATUS (Status); 0360 } 0361 0362 ACPI_EXPORT_SYMBOL_INIT (AcpiReallocateRootTable) 0363 0364 0365 /******************************************************************************* 0366 * 0367 * FUNCTION: AcpiGetTableHeader 0368 * 0369 * PARAMETERS: Signature - ACPI signature of needed table 0370 * Instance - Which instance (for SSDTs) 0371 * OutTableHeader - The pointer to the where the table header 0372 * is returned 0373 * 0374 * RETURN: Status and a copy of the table header 0375 * 0376 * DESCRIPTION: Finds and returns an ACPI table header. Caller provides the 0377 * memory where a copy of the header is to be returned 0378 * (fixed length). 0379 * 0380 ******************************************************************************/ 0381 0382 ACPI_STATUS 0383 AcpiGetTableHeader ( 0384 char *Signature, 0385 UINT32 Instance, 0386 ACPI_TABLE_HEADER *OutTableHeader) 0387 { 0388 UINT32 i; 0389 UINT32 j; 0390 ACPI_TABLE_HEADER *Header; 0391 0392 0393 /* Parameter validation */ 0394 0395 if (!Signature || !OutTableHeader) 0396 { 0397 return (AE_BAD_PARAMETER); 0398 } 0399 0400 /* Walk the root table list */ 0401 0402 for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) 0403 { 0404 if (!ACPI_COMPARE_NAMESEG ( 0405 &(AcpiGbl_RootTableList.Tables[i].Signature), Signature)) 0406 { 0407 continue; 0408 } 0409 0410 if (++j < Instance) 0411 { 0412 continue; 0413 } 0414 0415 if (!AcpiGbl_RootTableList.Tables[i].Pointer) 0416 { 0417 if ((AcpiGbl_RootTableList.Tables[i].Flags & 0418 ACPI_TABLE_ORIGIN_MASK) == 0419 ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL) 0420 { 0421 Header = AcpiOsMapMemory ( 0422 AcpiGbl_RootTableList.Tables[i].Address, 0423 sizeof (ACPI_TABLE_HEADER)); 0424 if (!Header) 0425 { 0426 return (AE_NO_MEMORY); 0427 } 0428 0429 memcpy (OutTableHeader, Header, sizeof (ACPI_TABLE_HEADER)); 0430 AcpiOsUnmapMemory (Header, sizeof (ACPI_TABLE_HEADER)); 0431 } 0432 else 0433 { 0434 return (AE_NOT_FOUND); 0435 } 0436 } 0437 else 0438 { 0439 memcpy (OutTableHeader, 0440 AcpiGbl_RootTableList.Tables[i].Pointer, 0441 sizeof (ACPI_TABLE_HEADER)); 0442 } 0443 0444 return (AE_OK); 0445 } 0446 0447 return (AE_NOT_FOUND); 0448 } 0449 0450 ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) 0451 0452 0453 /******************************************************************************* 0454 * 0455 * FUNCTION: AcpiGetTable 0456 * 0457 * PARAMETERS: Signature - ACPI signature of needed table 0458 * Instance - Which instance (for SSDTs) 0459 * OutTable - Where the pointer to the table is returned 0460 * 0461 * RETURN: Status and pointer to the requested table 0462 * 0463 * DESCRIPTION: Finds and verifies an ACPI table. Table must be in the 0464 * RSDT/XSDT. 0465 * Note that an early stage AcpiGetTable() call must be paired 0466 * with an early stage AcpiPutTable() call. otherwise the table 0467 * pointer mapped by the early stage mapping implementation may be 0468 * erroneously unmapped by the late stage unmapping implementation 0469 * in an AcpiPutTable() invoked during the late stage. 0470 * 0471 ******************************************************************************/ 0472 0473 ACPI_STATUS 0474 AcpiGetTable ( 0475 char *Signature, 0476 UINT32 Instance, 0477 ACPI_TABLE_HEADER **OutTable) 0478 { 0479 UINT32 i; 0480 UINT32 j; 0481 ACPI_STATUS Status = AE_NOT_FOUND; 0482 ACPI_TABLE_DESC *TableDesc; 0483 0484 0485 /* Parameter validation */ 0486 0487 if (!Signature || !OutTable) 0488 { 0489 return (AE_BAD_PARAMETER); 0490 } 0491 0492 /* 0493 * Note that the following line is required by some OSPMs, they only 0494 * check if the returned table is NULL instead of the returned status 0495 * to determined if this function is succeeded. 0496 */ 0497 *OutTable = NULL; 0498 0499 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 0500 0501 /* Walk the root table list */ 0502 0503 for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) 0504 { 0505 TableDesc = &AcpiGbl_RootTableList.Tables[i]; 0506 0507 if (!ACPI_COMPARE_NAMESEG (&TableDesc->Signature, Signature)) 0508 { 0509 continue; 0510 } 0511 0512 if (++j < Instance) 0513 { 0514 continue; 0515 } 0516 0517 Status = AcpiTbGetTable (TableDesc, OutTable); 0518 break; 0519 } 0520 0521 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 0522 return (Status); 0523 } 0524 0525 ACPI_EXPORT_SYMBOL (AcpiGetTable) 0526 0527 0528 /******************************************************************************* 0529 * 0530 * FUNCTION: AcpiPutTable 0531 * 0532 * PARAMETERS: Table - The pointer to the table 0533 * 0534 * RETURN: None 0535 * 0536 * DESCRIPTION: Release a table returned by AcpiGetTable() and its clones. 0537 * Note that it is not safe if this function was invoked after an 0538 * uninstallation happened to the original table descriptor. 0539 * Currently there is no OSPMs' requirement to handle such 0540 * situations. 0541 * 0542 ******************************************************************************/ 0543 0544 void 0545 AcpiPutTable ( 0546 ACPI_TABLE_HEADER *Table) 0547 { 0548 UINT32 i; 0549 ACPI_TABLE_DESC *TableDesc; 0550 0551 0552 ACPI_FUNCTION_TRACE (AcpiPutTable); 0553 0554 0555 if (!Table) 0556 { 0557 return_VOID; 0558 } 0559 0560 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 0561 0562 /* Walk the root table list */ 0563 0564 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) 0565 { 0566 TableDesc = &AcpiGbl_RootTableList.Tables[i]; 0567 0568 if (TableDesc->Pointer != Table) 0569 { 0570 continue; 0571 } 0572 0573 AcpiTbPutTable (TableDesc); 0574 break; 0575 } 0576 0577 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 0578 return_VOID; 0579 } 0580 0581 ACPI_EXPORT_SYMBOL (AcpiPutTable) 0582 0583 0584 /******************************************************************************* 0585 * 0586 * FUNCTION: AcpiGetTableByIndex 0587 * 0588 * PARAMETERS: TableIndex - Table index 0589 * OutTable - Where the pointer to the table is returned 0590 * 0591 * RETURN: Status and pointer to the requested table 0592 * 0593 * DESCRIPTION: Obtain a table by an index into the global table list. Used 0594 * internally also. 0595 * 0596 ******************************************************************************/ 0597 0598 ACPI_STATUS 0599 AcpiGetTableByIndex ( 0600 UINT32 TableIndex, 0601 ACPI_TABLE_HEADER **OutTable) 0602 { 0603 ACPI_STATUS Status; 0604 0605 0606 ACPI_FUNCTION_TRACE (AcpiGetTableByIndex); 0607 0608 0609 /* Parameter validation */ 0610 0611 if (!OutTable) 0612 { 0613 return_ACPI_STATUS (AE_BAD_PARAMETER); 0614 } 0615 0616 /* 0617 * Note that the following line is required by some OSPMs, they only 0618 * check if the returned table is NULL instead of the returned status 0619 * to determined if this function is succeeded. 0620 */ 0621 *OutTable = NULL; 0622 0623 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); 0624 0625 /* Validate index */ 0626 0627 if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount) 0628 { 0629 Status = AE_BAD_PARAMETER; 0630 goto UnlockAndExit; 0631 } 0632 0633 Status = AcpiTbGetTable ( 0634 &AcpiGbl_RootTableList.Tables[TableIndex], OutTable); 0635 0636 UnlockAndExit: 0637 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); 0638 return_ACPI_STATUS (Status); 0639 } 0640 0641 ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex) 0642 0643 0644 /******************************************************************************* 0645 * 0646 * FUNCTION: AcpiInstallTableHandler 0647 * 0648 * PARAMETERS: Handler - Table event handler 0649 * Context - Value passed to the handler on each event 0650 * 0651 * RETURN: Status 0652 * 0653 * DESCRIPTION: Install a global table event handler. 0654 * 0655 ******************************************************************************/ 0656 0657 ACPI_STATUS 0658 AcpiInstallTableHandler ( 0659 ACPI_TABLE_HANDLER Handler, 0660 void *Context) 0661 { 0662 ACPI_STATUS Status; 0663 0664 0665 ACPI_FUNCTION_TRACE (AcpiInstallTableHandler); 0666 0667 0668 if (!Handler) 0669 { 0670 return_ACPI_STATUS (AE_BAD_PARAMETER); 0671 } 0672 0673 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 0674 if (ACPI_FAILURE (Status)) 0675 { 0676 return_ACPI_STATUS (Status); 0677 } 0678 0679 /* Don't allow more than one handler */ 0680 0681 if (AcpiGbl_TableHandler) 0682 { 0683 Status = AE_ALREADY_EXISTS; 0684 goto Cleanup; 0685 } 0686 0687 /* Install the handler */ 0688 0689 AcpiGbl_TableHandler = Handler; 0690 AcpiGbl_TableHandlerContext = Context; 0691 0692 Cleanup: 0693 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 0694 return_ACPI_STATUS (Status); 0695 } 0696 0697 ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler) 0698 0699 0700 /******************************************************************************* 0701 * 0702 * FUNCTION: AcpiRemoveTableHandler 0703 * 0704 * PARAMETERS: Handler - Table event handler that was installed 0705 * previously. 0706 * 0707 * RETURN: Status 0708 * 0709 * DESCRIPTION: Remove a table event handler 0710 * 0711 ******************************************************************************/ 0712 0713 ACPI_STATUS 0714 AcpiRemoveTableHandler ( 0715 ACPI_TABLE_HANDLER Handler) 0716 { 0717 ACPI_STATUS Status; 0718 0719 0720 ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler); 0721 0722 0723 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); 0724 if (ACPI_FAILURE (Status)) 0725 { 0726 return_ACPI_STATUS (Status); 0727 } 0728 0729 /* Make sure that the installed handler is the same */ 0730 0731 if (!Handler || 0732 Handler != AcpiGbl_TableHandler) 0733 { 0734 Status = AE_BAD_PARAMETER; 0735 goto Cleanup; 0736 } 0737 0738 /* Remove the handler */ 0739 0740 AcpiGbl_TableHandler = NULL; 0741 0742 Cleanup: 0743 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); 0744 return_ACPI_STATUS (Status); 0745 } 0746 0747 ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler)
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |