osunixxf.c revision 118617
1105197Ssam/****************************************************************************** 2105197Ssam * 3105197Ssam * Module Name: osunixxf - UNIX OSL interfaces 4139823Simp * 5105197Ssam *****************************************************************************/ 6105197Ssam 7105197Ssam/****************************************************************************** 8105197Ssam * 9105197Ssam * 1. Copyright Notice 10105197Ssam * 11105197Ssam * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. 12105197Ssam * All rights reserved. 13105197Ssam * 14105197Ssam * 2. License 15105197Ssam * 16105197Ssam * 2.1. This is your license from Intel Corp. under its intellectual property 17105197Ssam * rights. You may have additional license terms from the party that provided 18105197Ssam * you this software, covering your right to use that party's intellectual 19105197Ssam * property rights. 20105197Ssam * 21105197Ssam * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22105197Ssam * copy of the source code appearing in this file ("Covered Code") an 23105197Ssam * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24105197Ssam * base code distributed originally by Intel ("Original Intel Code") to copy, 25105197Ssam * make derivatives, distribute, use and display any portion of the Covered 26105197Ssam * Code in any form, with the right to sublicense such rights; and 27105197Ssam * 28105197Ssam * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29105197Ssam * license (with the right to sublicense), under only those claims of Intel 30105197Ssam * patents that are infringed by the Original Intel Code, to make, use, sell, 31105197Ssam * offer to sell, and import the Covered Code and derivative works thereof 32105197Ssam * solely to the minimum extent necessary to exercise the above copyright 33105197Ssam * license, and in no event shall the patent license extend to any additions 34105197Ssam * to or modifications of the Original Intel Code. No other license or right 35105197Ssam * is granted directly or by implication, estoppel or otherwise; 36105197Ssam * 37105197Ssam * The above copyright and patent license is granted only if the following 38119643Ssam * conditions are met: 39119643Ssam * 40220206Sfabient * 3. Conditions 41105197Ssam * 42105197Ssam * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43105197Ssam * Redistribution of source code of any substantial portion of the Covered 44105197Ssam * Code or modification with rights to further distribute source must include 45105197Ssam * the above Copyright Notice, the above License, this list of Conditions, 46105197Ssam * and the following Disclaimer and Export Compliance provision. In addition, 47105197Ssam * Licensee must cause all Covered Code to which Licensee contributes to 48105197Ssam * contain a file documenting the changes Licensee made to create that Covered 49105197Ssam * Code and the date of any change. Licensee must include in that file the 50298535Sae * documentation of any changes made by any predecessor Licensee. Licensee 51105197Ssam * must include a prominent statement that the modification is derived, 52298535Sae * directly or indirectly, from Original Intel Code. 53195699Srwatson * 54195699Srwatson * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55105197Ssam * Redistribution of source code of any substantial portion of the Covered 56105197Ssam * Code or modification without rights to further distribute source must 57105197Ssam * include the following Disclaimer and Export Compliance provision in the 58105197Ssam * documentation and/or other materials provided with distribution. In 59105197Ssam * addition, Licensee may not authorize further sublicense of source of any 60298549Sae * portion of the Covered Code, and must include terms to the effect that the 61105197Ssam * license from Licensee to its licensee is limited to the intellectual 62105197Ssam * property embodied in the software Licensee provides to its licensee, and 63105197Ssam * not to intellectual property embodied in modifications its licensee may 64105197Ssam * make. 65105197Ssam * 66105197Ssam * 3.3. Redistribution of Executable. Redistribution in executable form of any 67105197Ssam * substantial portion of the Covered Code or modification must reproduce the 68105197Ssam * above Copyright Notice, and the following Disclaimer and Export Compliance 69105197Ssam * provision in the documentation and/or other materials provided with the 70105197Ssam * distribution. 71105197Ssam * 72105197Ssam * 3.4. Intel retains all right, title, and interest in and to the Original 73199947Sbz * Intel Code. 74253088Sae * 75253088Sae * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76105197Ssam * Intel shall be used in advertising or otherwise to promote the sale, use or 77253088Sae * other dealings in products derived from or relating to the Covered Code 78253088Sae * without prior written authorization from Intel. 79253088Sae * 80253088Sae * 4. Disclaimer and Export Compliance 81105197Ssam * 82274225Sglebius * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83274225Sglebius * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84253088Sae * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85253088Sae * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86253088Sae * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87105197Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88105197Ssam * PARTICULAR PURPOSE. 89105197Ssam * 90105197Ssam * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91105197Ssam * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92105197Ssam * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93105197Ssam * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94105197Ssam * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95105197Ssam * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96105197Ssam * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97105197Ssam * LIMITED REMEDY. 98105197Ssam * 99105197Ssam * 4.3. Licensee shall not export, either directly or indirectly, any of this 100105197Ssam * software or system incorporating such software without first obtaining any 101105197Ssam * required license or other approval from the U. S. Department of Commerce or 102105197Ssam * any other agency or department of the United States Government. In the 103105197Ssam * event Licensee exports any such software from the United States or 104298535Sae * re-exports any such software from a foreign destination, Licensee shall 105298535Sae * ensure that the distribution and export/re-export of the software is in 106298535Sae * compliance with all laws, regulations, orders, or other restrictions of the 107298535Sae * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108298535Sae * any of its subsidiaries will export/re-export any technical data, process, 109298535Sae * software, or service, directly or indirectly, to any country for which the 110298535Sae * United States government or any agency thereof requires an export license, 111298535Sae * other governmental approval, or letter of assurance, without first obtaining 112298535Sae * such license, approval or letter. 113298535Sae * 114298535Sae *****************************************************************************/ 115298535Sae 116298535Sae 117298535Sae/* 118298535Sae * These interfaces are required in order to compile the ASL compiler under 119298535Sae * Linux. 120298535Sae */ 121298535Sae 122298535Sae#include <stdio.h> 123298535Sae#include <stdlib.h> 124298535Sae#include <stdarg.h> 125298535Sae#include <unistd.h> 126298535Sae#include <sys/time.h> 127298535Sae 128298535Sae#include "acpi.h" 129298535Sae#include "amlcode.h" 130298535Sae#include "acparser.h" 131298535Sae#include "acdebug.h" 132298535Sae 133298535Sae#define _COMPONENT ACPI_OS_SERVICES 134298535Sae ACPI_MODULE_NAME ("osunixxf") 135298535Sae 136298535Sae 137298535Saeextern FILE *AcpiGbl_DebugFile; 138298535SaeFILE *AcpiGbl_OutputFile; 139298535Sae 140298535Sae 141298535Sae/****************************************************************************** 142298535Sae * 143298535Sae * FUNCTION: AcpiOsInitialize, AcpiOsTerminate 144298535Sae * 145298535Sae * PARAMETERS: None 146298535Sae * 147298535Sae * RETURN: Status 148298535Sae * 149298535Sae * DESCRIPTION: Init and terminate. Nothing to do. 150298535Sae * 151298535Sae *****************************************************************************/ 152298535Sae 153298535SaeACPI_STATUS 154298535SaeAcpiOsInitialize (void) 155298535Sae{ 156298535Sae AcpiGbl_OutputFile = stdout; 157298535Sae 158298535Sae return AE_OK; 159105197Ssam} 160105197Ssam 161105197Ssam 162105197SsamACPI_STATUS 163105197SsamAcpiOsTerminate (void) 164105197Ssam{ 165105197Ssam return AE_OK; 166105197Ssam} 167105197Ssam 168105197Ssam 169105197Ssam/****************************************************************************** 170120585Ssam * 171105197Ssam * FUNCTION: AcpiOsGetRootPointer 172105197Ssam * 173105197Ssam * PARAMETERS: Flags - Logical or physical addressing mode 174105197Ssam * Address - Where the address is returned 175105197Ssam * 176105197Ssam * RETURN: Status 177105197Ssam * 178105197Ssam * DESCRIPTION: Gets the root pointer (RSDP) 179105197Ssam * 180105197Ssam *****************************************************************************/ 181105197Ssam 182181803SbzACPI_STATUS 183105197SsamAcpiOsGetRootPointer ( 184105197Ssam UINT32 Flags, 185105197Ssam ACPI_POINTER *Address) 186105197Ssam{ 187105197Ssam 188105197Ssam return (AE_OK); 189105197Ssam} 190105197Ssam 191105197Ssam 192105197Ssam/****************************************************************************** 193105197Ssam * 194105197Ssam * FUNCTION: AcpiOsPredefinedOverride 195105197Ssam * 196105197Ssam * PARAMETERS: InitVal - Initial value of the predefined object 197105197Ssam * NewVal - The new value for the object 198105197Ssam * 199105197Ssam * RETURN: Status, pointer to value. Null pointer returned if not 200105197Ssam * overriding. 201105197Ssam * 202105197Ssam * DESCRIPTION: Allow the OS to override predefined names 203105197Ssam * 204105197Ssam *****************************************************************************/ 205105197Ssam 206105197SsamACPI_STATUS 207220247SbzAcpiOsPredefinedOverride ( 208220247Sbz const ACPI_PREDEFINED_NAMES *InitVal, 209105197Ssam ACPI_STRING *NewVal) 210105197Ssam{ 211220247Sbz 212220247Sbz if (!InitVal || !NewVal) 213220247Sbz { 214220247Sbz return (AE_BAD_PARAMETER); 215220247Sbz } 216220247Sbz 217252028Sae *NewVal = NULL; 218220247Sbz return (AE_OK); 219220247Sbz} 220220247Sbz 221220247Sbz 222220247Sbz/****************************************************************************** 223220247Sbz * 224220247Sbz * FUNCTION: AcpiOsTableOverride 225252028Sae * 226220247Sbz * PARAMETERS: ExistingTable - Header of current table (probably firmware) 227220247Sbz * NewTable - Where an entire new table is returned. 228220247Sbz * 229220247Sbz * RETURN: Status, pointer to new table. Null pointer returned if no 230105197Ssam * table is available to override 231105197Ssam * 232105197Ssam * DESCRIPTION: Return a different version of a table if one is available 233105197Ssam * 234120585Ssam *****************************************************************************/ 235252028Sae 236105197SsamACPI_STATUS 237105197SsamAcpiOsTableOverride ( 238105197Ssam ACPI_TABLE_HEADER *ExistingTable, 239105197Ssam ACPI_TABLE_HEADER **NewTable) 240105197Ssam{ 241105197Ssam if (!ExistingTable || !NewTable) 242105197Ssam { 243120585Ssam return (AE_BAD_PARAMETER); 244252028Sae } 245105197Ssam 246105197Ssam *NewTable = NULL; 247105197Ssam return (AE_OK); 248105197Ssam} 249105197Ssam 250105197Ssam 251105197Ssam/****************************************************************************** 252105197Ssam * 253105197Ssam * FUNCTION: AcpiOsReadable 254105197Ssam * 255105197Ssam * PARAMETERS: Pointer - Area to be verified 256105197Ssam * Length - Size of area 257105197Ssam * 258105197Ssam * RETURN: TRUE if readable for entire length 259105197Ssam * 260117058Ssam * DESCRIPTION: Verify that a pointer is valid for reading 261105197Ssam * 262105197Ssam *****************************************************************************/ 263105197Ssam 264105197SsamBOOLEAN 265105197SsamAcpiOsReadable ( 266105197Ssam void *Pointer, 267105197Ssam ACPI_SIZE Length) 268105197Ssam{ 269105197Ssam 270105197Ssam return (TRUE); 271105197Ssam} 272220206Sfabient 273220206Sfabient 274105197Ssam/****************************************************************************** 275105197Ssam * 276105197Ssam * FUNCTION: AcpiOsWritable 277105197Ssam * 278105197Ssam * PARAMETERS: Pointer - Area to be verified 279105197Ssam * Length - Size of area 280105197Ssam * 281105197Ssam * RETURN: TRUE if writable for entire length 282105197Ssam * 283105197Ssam * DESCRIPTION: Verify that a pointer is valid for writing 284281695Sae * 285105197Ssam *****************************************************************************/ 286105197Ssam 287105197SsamBOOLEAN 288105197SsamAcpiOsWritable ( 289105197Ssam void *Pointer, 290105197Ssam ACPI_SIZE Length) 291119643Ssam{ 292105197Ssam 293105197Ssam return (TRUE); 294105197Ssam} 295105197Ssam 296105197Ssam 297105197Ssam/****************************************************************************** 298120585Ssam * 299105197Ssam * FUNCTION: AcpiOsRedirectOutput 300105197Ssam * 301105197Ssam * PARAMETERS: Destination - An open file handle/pointer 302105197Ssam * 303220206Sfabient * RETURN: None 304220206Sfabient * 305105197Ssam * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf 306105197Ssam * 307120585Ssam *****************************************************************************/ 308105197Ssam 309120585Ssamvoid 310105197SsamAcpiOsRedirectOutput ( 311105197Ssam void *Destination) 312105197Ssam{ 313105197Ssam 314105197Ssam AcpiGbl_OutputFile = Destination; 315105197Ssam} 316105197Ssam 317105197Ssam 318199905Sbz/****************************************************************************** 319105197Ssam * 320252028Sae * FUNCTION: AcpiOsPrintf 321120585Ssam * 322105197Ssam * PARAMETERS: fmt, ... Standard printf format 323105197Ssam * 324105197Ssam * RETURN: None 325105197Ssam * 326105197Ssam * DESCRIPTION: Formatted output 327252028Sae * 328120585Ssam *****************************************************************************/ 329105197Ssam 330105197Ssamvoid ACPI_INTERNAL_VAR_XFACE 331105197SsamAcpiOsPrintf ( 332252028Sae const char *Fmt, 333105197Ssam ...) 334105197Ssam{ 335105197Ssam va_list Args; 336105197Ssam 337105197Ssam 338105197Ssam va_start (Args, Fmt); 339105197Ssam 340105197Ssam AcpiOsVprintf (Fmt, Args); 341105197Ssam 342105197Ssam va_end (Args); 343298075Spfg return; 344252028Sae} 345120585Ssam 346105197Ssam 347105197Ssam/****************************************************************************** 348105197Ssam * 349105197Ssam * FUNCTION: AcpiOsVprintf 350105197Ssam * 351105197Ssam * PARAMETERS: fmt Standard printf format 352105197Ssam * args Argument list 353105197Ssam * 354105197Ssam * RETURN: None 355105197Ssam * 356105197Ssam * DESCRIPTION: Formatted output with argument list pointer 357252028Sae * 358120585Ssam *****************************************************************************/ 359281695Sae 360281695Saevoid 361105197SsamAcpiOsVprintf ( 362105197Ssam const char *Fmt, 363105197Ssam va_list Args) 364105197Ssam{ 365105197Ssam INT32 Count = 0; 366105197Ssam UINT8 Flags; 367221129Sbz 368221129Sbz 369221129Sbz Flags = AcpiGbl_DbOutputFlags; 370275707Sae if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT) 371221129Sbz { 372221129Sbz /* Output is directable to either a file (if open) or the console */ 373221129Sbz 374221129Sbz if (AcpiGbl_DebugFile) 375275707Sae { 376221129Sbz /* Output file is open, send the output there */ 377221129Sbz 378221129Sbz Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args); 379221129Sbz } 380221129Sbz else 381221129Sbz { 382105197Ssam /* No redirection, send output to console (once only!) */ 383105197Ssam 384105197Ssam Flags |= ACPI_DB_CONSOLE_OUTPUT; 385105197Ssam } 386105197Ssam } 387105197Ssam 388105197Ssam if (Flags & ACPI_DB_CONSOLE_OUTPUT) 389105197Ssam { 390105197Ssam Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args); 391105197Ssam } 392105197Ssam 393105197Ssam return; 394105197Ssam} 395105197Ssam 396105197Ssam 397105197Ssam/****************************************************************************** 398105197Ssam * 399105197Ssam * FUNCTION: AcpiOsGetLine 400105197Ssam * 401281695Sae * PARAMETERS: fmt Standard printf format 402281695Sae * args Argument list 403105197Ssam * 404281695Sae * RETURN: Actual bytes read 405105197Ssam * 406105197Ssam * DESCRIPTION: Formatted input with argument list pointer 407199899Sbz * 408105197Ssam *****************************************************************************/ 409105197Ssam 410105197SsamUINT32 411105197SsamAcpiOsGetLine ( 412105197Ssam char *Buffer) 413120585Ssam{ 414105197Ssam UINT8 Temp; 415120585Ssam UINT32 i; 416105197Ssam 417199896Sbz 418199896Sbz for (i = 0; ; i++) 419199896Sbz { 420199896Sbz scanf ("%1c", &Temp); 421199896Sbz if (!Temp || Temp == '\n') 422199896Sbz { 423199896Sbz break; 424252028Sae } 425199896Sbz 426199896Sbz Buffer [i] = Temp; 427199896Sbz } 428105197Ssam 429252028Sae /* Null terminate the buffer */ 430105197Ssam 431105197Ssam Buffer [i] = 0; 432105197Ssam 433105197Ssam /* Return the number of bytes in the string */ 434105197Ssam 435199897Sbz return (i); 436105197Ssam} 437105197Ssam 438105197Ssam/****************************************************************************** 439105197Ssam * 440199897Sbz * FUNCTION: AcpiOsMapMemory 441105197Ssam * 442105197Ssam * PARAMETERS: where Physical address of memory to be mapped 443105197Ssam * length How much memory to map 444252028Sae * there Logical address of mapped memory 445120585Ssam * 446120585Ssam * RETURN: Pointer to mapped memory. Null on error. 447105197Ssam * 448281695Sae * DESCRIPTION: Map physical memory into caller's address space 449105197Ssam * 450105197Ssam *****************************************************************************/ 451105197Ssam 452105197SsamACPI_STATUS 453199899SbzAcpiOsMapMemory ( 454252028Sae ACPI_PHYSICAL_ADDRESS where, 455120585Ssam UINT32 length, 456120585Ssam void **there) 457281695Sae{ 458105197Ssam *there = (void *) (UINT32) where; 459199899Sbz 460105197Ssam return AE_OK; 461105197Ssam} 462105197Ssam 463105197Ssam 464105197Ssam/****************************************************************************** 465252028Sae * 466105197Ssam * FUNCTION: AcpiOsUnmapMemory 467156756Ssam * 468105197Ssam * PARAMETERS: where Logical address of memory to be unmapped 469252028Sae * length How much memory to unmap 470120585Ssam * 471281695Sae * RETURN: None. 472281695Sae * 473105197Ssam * DESCRIPTION: Delete a previously created mapping. Where and Length must 474105197Ssam * correspond to a previous mapping exactly. 475105197Ssam * 476105197Ssam *****************************************************************************/ 477199899Sbz 478105197Ssamvoid 479105197SsamAcpiOsUnmapMemory ( 480105197Ssam void *where, 481105197Ssam UINT32 length) 482252028Sae{ 483120585Ssam 484105197Ssam return; 485105197Ssam} 486105197Ssam 487105197Ssam 488105197Ssam/****************************************************************************** 489105197Ssam * 490199899Sbz * FUNCTION: AcpiOsAllocate 491199899Sbz * 492105197Ssam * PARAMETERS: Size Amount to allocate, in bytes 493199899Sbz * 494105197Ssam * RETURN: Pointer to the new allocation. Null on error. 495105197Ssam * 496105197Ssam * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. 497105197Ssam * 498105197Ssam *****************************************************************************/ 499105197Ssam 500105197Ssamvoid * 501105197SsamAcpiOsAllocate ( 502252028Sae UINT32 size) 503120585Ssam{ 504105197Ssam void *Mem; 505105197Ssam 506105197Ssam 507105197Ssam Mem = (void *) malloc ((size_t) size); 508105197Ssam 509288418Sae return Mem; 510105197Ssam} 511220206Sfabient 512220206Sfabient 513105197Ssam/****************************************************************************** 514105197Ssam * 515105197Ssam * FUNCTION: AcpiOsFree 516199899Sbz * 517199899Sbz * PARAMETERS: mem Pointer to previously allocated memory 518105197Ssam * 519105197Ssam * RETURN: None. 520105197Ssam * 521117058Ssam * DESCRIPTION: Free memory allocated via AcpiOsAllocate 522105197Ssam * 523105197Ssam *****************************************************************************/ 524105197Ssam 525105197Ssamvoid 526105197SsamAcpiOsFree ( 527105197Ssam void *mem) 528105197Ssam{ 529105197Ssam 530105197Ssam 531105197Ssam free (mem); 532105197Ssam} 533105197Ssam 534105197Ssam 535105197Ssam/****************************************************************************** 536105197Ssam * 537105197Ssam * FUNCTION: AcpiOsCreateSemaphore 538105197Ssam * 539105197Ssam * PARAMETERS: InitialUnits - Units to be assigned to the new semaphore 540281695Sae * OutHandle - Where a handle will be returned 541105197Ssam * 542105197Ssam * RETURN: Status 543105197Ssam * 544105197Ssam * DESCRIPTION: Create an OS semaphore 545199899Sbz * 546105197Ssam *****************************************************************************/ 547105197Ssam 548120585SsamACPI_STATUS 549105197SsamAcpiOsCreateSemaphore ( 550105197Ssam UINT32 MaxUnits, 551105197Ssam UINT32 InitialUnits, 552105197Ssam ACPI_HANDLE *OutHandle) 553282046Sae{ 554120585Ssam 555220206Sfabient 556220206Sfabient *OutHandle = (ACPI_HANDLE) 1; 557220206Sfabient return AE_OK; 558252028Sae} 559120585Ssam 560105197Ssam/****************************************************************************** 561105197Ssam * 562105197Ssam * FUNCTION: AcpiOsDeleteSemaphore 563105197Ssam * 564105197Ssam * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 565105197Ssam * 566199905Sbz * RETURN: Status 567105197Ssam * 568105197Ssam * DESCRIPTION: Delete an OS semaphore 569105197Ssam * 570105197Ssam *****************************************************************************/ 571120585Ssam 572199899SbzACPI_STATUS 573105197SsamAcpiOsDeleteSemaphore ( 574252028Sae ACPI_HANDLE Handle) 575120585Ssam{ 576105197Ssam 577105197Ssam if (!Handle) 578105197Ssam { 579105197Ssam return AE_BAD_PARAMETER; 580105197Ssam } 581252028Sae 582120585Ssam return AE_OK; 583105197Ssam} 584105197Ssam 585105197Ssam 586252028Sae/****************************************************************************** 587105197Ssam * 588199899Sbz * FUNCTION: AcpiOsWaitSemaphore 589199899Sbz * 590199899Sbz * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 591199899Sbz * Units - How many units to wait for 592199899Sbz * Timeout - How long to wait 593199899Sbz * 594199899Sbz * RETURN: Status 595199899Sbz * 596199899Sbz * DESCRIPTION: Wait for units 597252028Sae * 598199899Sbz *****************************************************************************/ 599281695Sae 600281695SaeACPI_STATUS 601199899SbzAcpiOsWaitSemaphore ( 602199899Sbz ACPI_HANDLE Handle, 603199899Sbz UINT32 Units, 604199899Sbz UINT16 Timeout) 605199899Sbz{ 606199899Sbz 607199899Sbz 608199899Sbz return AE_OK; 609199899Sbz} 610199899Sbz 611199899Sbz 612199899Sbz/****************************************************************************** 613199899Sbz * 614199899Sbz * FUNCTION: AcpiOsSignalSemaphore 615199899Sbz * 616199899Sbz * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 617199899Sbz * Units - Number of units to send 618199899Sbz * 619199899Sbz * RETURN: Status 620199899Sbz * 621199899Sbz * DESCRIPTION: Send units 622199899Sbz * 623199899Sbz *****************************************************************************/ 624199899Sbz 625199899SbzACPI_STATUS 626199899SbzAcpiOsSignalSemaphore ( 627199899Sbz ACPI_HANDLE Handle, 628105197Ssam UINT32 Units) 629105197Ssam{ 630105197Ssam 631105197Ssam 632105197Ssam return AE_OK; 633105197Ssam} 634105197Ssam 635105197Ssam 636105197SsamACPI_STATUS 637105197SsamAcpiOsCreateLock ( 638105197Ssam ACPI_HANDLE *OutHandle) 639105197Ssam{ 640105197Ssam 641105197Ssam return (AcpiOsCreateSemaphore (1, 1, OutHandle)); 642252028Sae} 643120585Ssam 644120585Ssamvoid 645105197SsamAcpiOsDeleteLock ( 646281695Sae ACPI_HANDLE Handle) 647281695Sae{ 648105197Ssam AcpiOsDeleteSemaphore (Handle); 649105197Ssam} 650105197Ssam 651105197Ssam 652199946Sbzvoid 653252028SaeAcpiOsAcquireLock ( 654199946Sbz ACPI_HANDLE Handle, 655199946Sbz UINT32 Flags) 656199899Sbz{ 657199899Sbz AcpiOsWaitSemaphore (Handle, 1, 0xFFFF); 658105197Ssam} 659105197Ssam 660105197Ssam 661105197Ssamvoid 662105197SsamAcpiOsReleaseLock ( 663105197Ssam ACPI_HANDLE Handle, 664105197Ssam UINT32 Flags) 665105197Ssam{ 666105197Ssam AcpiOsSignalSemaphore (Handle, 1); 667120585Ssam} 668282046Sae 669282046Sae 670105197Ssam/****************************************************************************** 671105197Ssam * 672105197Ssam * FUNCTION: AcpiOsInstallInterruptHandler 673120585Ssam * 674282046Sae * PARAMETERS: InterruptNumber Level handler should respond to. 675105197Ssam * Isr Address of the ACPI interrupt handler 676105197Ssam * ExceptPtr Where status is returned 677105197Ssam * 678105197Ssam * RETURN: Handle to the newly installed handler. 679282046Sae * 680105197Ssam * DESCRIPTION: Install an interrupt handler. Used to install the ACPI 681105197Ssam * OS-independent handler. 682105197Ssam * 683105197Ssam *****************************************************************************/ 684105197Ssam 685105197SsamUINT32 686105197SsamAcpiOsInstallInterruptHandler ( 687105197Ssam UINT32 InterruptNumber, 688298535Sae OSD_HANDLER ServiceRoutine, 689298535Sae void *Context) 690298549Sae{ 691298549Sae 692298549Sae 693298549Sae return AE_OK; 694298549Sae} 695298549Sae 696298549Sae 697298549Sae/****************************************************************************** 698298549Sae * 699298549Sae * FUNCTION: AcpiOsRemoveInterruptHandler 700298549Sae * 701298549Sae * PARAMETERS: Handle Returned when handler was installed 702298535Sae * 703298535Sae * RETURN: Status 704298535Sae * 705298535Sae * DESCRIPTION: Uninstalls an interrupt handler. 706298535Sae * 707298535Sae *****************************************************************************/ 708298535Sae 709298535SaeACPI_STATUS 710298535SaeAcpiOsRemoveInterruptHandler ( 711298549Sae UINT32 InterruptNumber, 712298549Sae OSD_HANDLER ServiceRoutine) 713298535Sae{ 714298535Sae 715298535Sae return AE_OK; 716298535Sae} 717298535Sae 718298535Sae 719298535Sae/****************************************************************************** 720298535Sae * 721298535Sae * FUNCTION: AcpiOsQueueForExecution 722298535Sae * 723298535Sae * PARAMETERS: Priority - Requested execution priority 724298535Sae * Function - Address of the function to execute 725298549Sae * Context - Passed as a parameter to the function 726298549Sae * 727298549Sae * RETURN: Status. 728298549Sae * 729298549Sae * DESCRIPTION: Sleep at microsecond granularity 730298549Sae * 731298549Sae *****************************************************************************/ 732298549Sae 733298549SaeACPI_STATUS 734298549SaeAcpiOsQueueForExecution ( 735298549Sae UINT32 Priority, 736298549Sae OSD_EXECUTION_CALLBACK Function, 737298535Sae void *Context) 738298535Sae{ 739298535Sae 740298535Sae// _beginthread (Function, (unsigned) 0, Context); 741298535Sae return 0; 742298535Sae} 743298535Sae 744298535Sae 745298535Sae/****************************************************************************** 746298549Sae * 747298549Sae * FUNCTION: AcpiOsBreakpoint 748298535Sae * 749298535Sae * PARAMETERS: Msg Message to print 750298535Sae * 751298535Sae * RETURN: Status 752298535Sae * 753298535Sae * DESCRIPTION: Print a message and break to the debugger. 754298535Sae * 755298535Sae *****************************************************************************/ 756298535Sae 757298535SaeACPI_STATUS 758298535SaeAcpiOsBreakpoint ( 759298535Sae char *Msg) 760298535Sae{ 761298535Sae 762298535Sae /* Print the message and do an INT 3 */ 763298535Sae 764298535Sae if (Msg) 765298535Sae { 766298535Sae AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Msg); 767298535Sae } 768298535Sae else 769298535Sae { 770298535Sae AcpiOsPrintf ("At AcpiOsBreakpoint ****\n"); 771105197Ssam } 772105197Ssam 773105197Ssam 774185088Szec return AE_OK; 775298535Sae} 776298549Sae 777298549Sae 778298535Sae/****************************************************************************** 779298535Sae * 780298549Sae * FUNCTION: AcpiOsSleepUsec 781298549Sae * 782298535Sae * PARAMETERS: microseconds To sleep 783105197Ssam * 784105197Ssam * RETURN: Blocks until sleep is completed. 785190787Szec * 786298535Sae * DESCRIPTION: Sleep at microsecond granularity 787298535Sae * 788 *****************************************************************************/ 789 790void 791AcpiOsStall ( 792 UINT32 microseconds) 793{ 794 795 return; 796} 797 798 799/****************************************************************************** 800 * 801 * FUNCTION: AcpiOsSleep 802 * 803 * PARAMETERS: seconds To sleep 804 * milliseconds To sleep 805 * 806 * RETURN: Blocks until sleep is completed. 807 * 808 * DESCRIPTION: Sleep at second/millisecond granularity 809 * 810 *****************************************************************************/ 811 812void 813AcpiOsSleep ( 814 UINT32 seconds, 815 UINT32 milliseconds) 816{ 817 818 sleep ((seconds * 1000) + milliseconds); 819 return; 820} 821 822/****************************************************************************** 823 * 824 * FUNCTION: AcpiOsGetTimer 825 * 826 * PARAMETERS: None 827 * 828 * RETURN: Current time in milliseconds 829 * 830 * DESCRIPTION: Get the current system time (in milliseconds). 831 * 832 *****************************************************************************/ 833 834UINT32 835AcpiOsGetTimer (void) 836{ 837 struct timeval time; 838 839 gettimeofday(&time, NULL); 840 841 return ((time.tv_sec/1000) + (time.tv_usec*1000)); 842} 843 844 845/****************************************************************************** 846 * 847 * FUNCTION: AcpiOsReadPciConfiguration 848 * 849 * PARAMETERS: PciId Seg/Bus/Dev 850 * Register Device Register 851 * Value Buffer where value is placed 852 * Width Number of bits 853 * 854 * RETURN: Status 855 * 856 * DESCRIPTION: Read data from PCI configuration space 857 * 858 *****************************************************************************/ 859 860ACPI_STATUS 861AcpiOsReadPciConfiguration ( 862 ACPI_PCI_ID *PciId, 863 UINT32 Register, 864 void *Value, 865 UINT32 Width) 866{ 867 868 return (AE_OK); 869} 870 871 872/****************************************************************************** 873 * 874 * FUNCTION: AcpiOsWritePciConfiguration 875 * 876 * PARAMETERS: PciId Seg/Bus/Dev 877 * Register Device Register 878 * Value Value to be written 879 * Width Number of bits 880 * 881 * RETURN: Status. 882 * 883 * DESCRIPTION: Write data to PCI configuration space 884 * 885 *****************************************************************************/ 886 887ACPI_STATUS 888AcpiOsWritePciConfiguration ( 889 ACPI_PCI_ID *PciId, 890 UINT32 Register, 891 ACPI_INTEGER Value, 892 UINT32 Width) 893{ 894 895 return (AE_OK); 896} 897 898/* TEMPORARY STUB FUNCTION */ 899void 900AcpiOsDerivePciId( 901 ACPI_HANDLE rhandle, 902 ACPI_HANDLE chandle, 903 ACPI_PCI_ID **PciId) 904{ 905 906} 907 908 909/****************************************************************************** 910 * 911 * FUNCTION: AcpiOsReadPort 912 * 913 * PARAMETERS: Address Address of I/O port/register to read 914 * Value Where value is placed 915 * Width Number of bits 916 * 917 * RETURN: Value read from port 918 * 919 * DESCRIPTION: Read data from an I/O port or register 920 * 921 *****************************************************************************/ 922 923ACPI_STATUS 924AcpiOsReadPort ( 925 ACPI_IO_ADDRESS Address, 926 UINT32 *Value, 927 UINT32 Width) 928{ 929 930 switch (Width) 931 { 932 case 8: 933 *Value = 0xFF; 934 break; 935 936 case 16: 937 *Value = 0xFFFF; 938 break; 939 940 case 32: 941 *Value = 0xFFFFFFFF; 942 break; 943 } 944 945 return (AE_OK); 946} 947 948 949/****************************************************************************** 950 * 951 * FUNCTION: AcpiOsWritePort 952 * 953 * PARAMETERS: Address Address of I/O port/register to write 954 * Value Value to write 955 * Width Number of bits 956 * 957 * RETURN: None 958 * 959 * DESCRIPTION: Write data to an I/O port or register 960 * 961 *****************************************************************************/ 962 963ACPI_STATUS 964AcpiOsWritePort ( 965 ACPI_IO_ADDRESS Address, 966 UINT32 Value, 967 UINT32 Width) 968{ 969 970 return (AE_OK); 971} 972 973 974/****************************************************************************** 975 * 976 * FUNCTION: AcpiOsReadMemory 977 * 978 * PARAMETERS: Address Physical Memory Address to read 979 * Value Where value is placed 980 * Width Number of bits 981 * 982 * RETURN: Value read from physical memory address 983 * 984 * DESCRIPTION: Read data from a physical memory address 985 * 986 *****************************************************************************/ 987 988ACPI_STATUS 989AcpiOsReadMemory ( 990 ACPI_PHYSICAL_ADDRESS Address, 991 UINT32 *Value, 992 UINT32 Width) 993{ 994 995 switch (Width) 996 { 997 case 8: 998 case 16: 999 case 32: 1000 *Value = 0; 1001 break; 1002 1003 default: 1004 return (AE_BAD_PARAMETER); 1005 break; 1006 } 1007 return (AE_OK); 1008} 1009 1010 1011/****************************************************************************** 1012 * 1013 * FUNCTION: AcpiOsWriteMemory 1014 * 1015 * PARAMETERS: Address Physical Memory Address to write 1016 * Value Value to write 1017 * Width Number of bits 1018 * 1019 * RETURN: None 1020 * 1021 * DESCRIPTION: Write data to a physical memory address 1022 * 1023 *****************************************************************************/ 1024 1025ACPI_STATUS 1026AcpiOsWriteMemory ( 1027 ACPI_PHYSICAL_ADDRESS Address, 1028 UINT32 Value, 1029 UINT32 Width) 1030{ 1031 1032 return (AE_OK); 1033} 1034 1035 1036UINT32 1037AcpiOsGetThreadId(void) 1038{ 1039 return getpid(); 1040} 1041 1042 1043/****************************************************************************** 1044 * 1045 * FUNCTION: AcpiOsSignal 1046 * 1047 * PARAMETERS: Function ACPI CA signal function code 1048 * Info Pointer to function-dependent structure 1049 * 1050 * RETURN: Status 1051 * 1052 * DESCRIPTION: Miscellaneous functions 1053 * 1054 *****************************************************************************/ 1055 1056ACPI_STATUS 1057AcpiOsSignal ( 1058 UINT32 Function, 1059 void *Info) 1060{ 1061 1062 switch (Function) 1063 { 1064 case ACPI_SIGNAL_FATAL: 1065 break; 1066 1067 case ACPI_SIGNAL_BREAKPOINT: 1068 1069 if (Info) 1070 { 1071 AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info); 1072 } 1073 else 1074 { 1075 AcpiOsPrintf ("At AcpiOsBreakpoint ****\n"); 1076 } 1077 1078 break; 1079 } 1080 1081 1082 return (AE_OK); 1083} 1084 1085 1086