1 /****************************************************************************** 2 * 3 * Module Name: osunixxf - UNIX OSL interfaces 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2011, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 45 /* 46 * These interfaces are required in order to compile the ASL compiler and the 47 * various ACPICA tools under Linux or other Unix-like system. 48 * 49 * Note: Use #define __APPLE__ for OS X generation. 50 */ 51 #include <contrib/dev/acpica/include/acpi.h> 52 #include <contrib/dev/acpica/include/accommon.h> 53 #include <contrib/dev/acpica/include/amlcode.h> 54 #include <contrib/dev/acpica/include/acparser.h> 55 #include <contrib/dev/acpica/include/acdebug.h> 56 57 #include <stdio.h> 58 #include <stdlib.h> 59 #include <stdarg.h> 60 #include <unistd.h> 61 #include <sys/time.h> 62 #include <semaphore.h> 63 #include <pthread.h> 64 #include <errno.h> 65 66 #define _COMPONENT ACPI_OS_SERVICES 67 ACPI_MODULE_NAME ("osunixxf") 68 69 70 extern FILE *AcpiGbl_DebugFile; 71 FILE *AcpiGbl_OutputFile; 72 73 74 /* Upcalls to AcpiExec */ 75 76 ACPI_PHYSICAL_ADDRESS 77 AeLocalGetRootPointer ( 78 void); 79 80 void 81 AeTableOverride ( 82 ACPI_TABLE_HEADER *ExistingTable, 83 ACPI_TABLE_HEADER **NewTable); 84 85 typedef void* (*PTHREAD_CALLBACK) (void *); 86 87 /* Apple-specific */ 88 89 #ifdef __APPLE__ 90 #define sem_destroy sem_close 91 #endif 92 93 94 /****************************************************************************** 95 * 96 * FUNCTION: AcpiOsInitialize, AcpiOsTerminate 97 * 98 * PARAMETERS: None 99 * 100 * RETURN: Status 101 * 102 * DESCRIPTION: Init and terminate. Nothing to do. 103 * 104 *****************************************************************************/ 105 106 ACPI_STATUS 107 AcpiOsInitialize ( 108 void) 109 { 110 111 AcpiGbl_OutputFile = stdout; 112 return (AE_OK); 113 } 114 115 116 ACPI_STATUS 117 AcpiOsTerminate ( 118 void) 119 { 120 121 return (AE_OK); 122 } 123 124 125 /****************************************************************************** 126 * 127 * FUNCTION: AcpiOsGetRootPointer 128 * 129 * PARAMETERS: None 130 * 131 * RETURN: RSDP physical address 132 * 133 * DESCRIPTION: Gets the ACPI root pointer (RSDP) 134 * 135 *****************************************************************************/ 136 137 ACPI_PHYSICAL_ADDRESS 138 AcpiOsGetRootPointer ( 139 void) 140 { 141 142 return (AeLocalGetRootPointer ()); 143 } 144 145 146 /****************************************************************************** 147 * 148 * FUNCTION: AcpiOsPredefinedOverride 149 * 150 * PARAMETERS: InitVal - Initial value of the predefined object 151 * NewVal - The new value for the object 152 * 153 * RETURN: Status, pointer to value. Null pointer returned if not 154 * overriding. 155 * 156 * DESCRIPTION: Allow the OS to override predefined names 157 * 158 *****************************************************************************/ 159 160 ACPI_STATUS 161 AcpiOsPredefinedOverride ( 162 const ACPI_PREDEFINED_NAMES *InitVal, 163 ACPI_STRING *NewVal) 164 { 165 166 if (!InitVal || !NewVal) 167 { 168 return (AE_BAD_PARAMETER); 169 } 170 171 *NewVal = NULL; 172 return (AE_OK); 173 } 174 175 176 /****************************************************************************** 177 * 178 * FUNCTION: AcpiOsTableOverride 179 * 180 * PARAMETERS: ExistingTable - Header of current table (probably 181 * firmware) 182 * NewTable - Where an entire new table is returned. 183 * 184 * RETURN: Status, pointer to new table. Null pointer returned if no 185 * table is available to override 186 * 187 * DESCRIPTION: Return a different version of a table if one is available 188 * 189 *****************************************************************************/ 190 191 ACPI_STATUS 192 AcpiOsTableOverride ( 193 ACPI_TABLE_HEADER *ExistingTable, 194 ACPI_TABLE_HEADER **NewTable) 195 { 196 197 if (!ExistingTable || !NewTable) 198 { 199 return (AE_BAD_PARAMETER); 200 } 201 202 *NewTable = NULL; 203 204 #ifdef ACPI_EXEC_APP 205 206 AeTableOverride (ExistingTable, NewTable); 207 return (AE_OK); 208 #else 209 210 return (AE_NO_ACPI_TABLES); 211 #endif 212 } 213 214 215 /****************************************************************************** 216 * 217 * FUNCTION: AcpiOsRedirectOutput 218 * 219 * PARAMETERS: Destination - An open file handle/pointer 220 * 221 * RETURN: None 222 * 223 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf 224 * 225 *****************************************************************************/ 226 227 void 228 AcpiOsRedirectOutput ( 229 void *Destination) 230 { 231 232 AcpiGbl_OutputFile = Destination; 233 } 234 235 236 /****************************************************************************** 237 * 238 * FUNCTION: AcpiOsPrintf 239 * 240 * PARAMETERS: fmt, ... - Standard printf format 241 * 242 * RETURN: None 243 * 244 * DESCRIPTION: Formatted output 245 * 246 *****************************************************************************/ 247 248 void ACPI_INTERNAL_VAR_XFACE 249 AcpiOsPrintf ( 250 const char *Fmt, 251 ...) 252 { 253 va_list Args; 254 255 256 va_start (Args, Fmt); 257 AcpiOsVprintf (Fmt, Args); 258 va_end (Args); 259 } 260 261 262 /****************************************************************************** 263 * 264 * FUNCTION: AcpiOsVprintf 265 * 266 * PARAMETERS: fmt - Standard printf format 267 * args - Argument list 268 * 269 * RETURN: None 270 * 271 * DESCRIPTION: Formatted output with argument list pointer 272 * 273 *****************************************************************************/ 274 275 void 276 AcpiOsVprintf ( 277 const char *Fmt, 278 va_list Args) 279 { 280 UINT8 Flags; 281 282 283 Flags = AcpiGbl_DbOutputFlags; 284 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT) 285 { 286 /* Output is directable to either a file (if open) or the console */ 287 288 if (AcpiGbl_DebugFile) 289 { 290 /* Output file is open, send the output there */ 291 292 vfprintf (AcpiGbl_DebugFile, Fmt, Args); 293 } 294 else 295 { 296 /* No redirection, send output to console (once only!) */ 297 298 Flags |= ACPI_DB_CONSOLE_OUTPUT; 299 } 300 } 301 302 if (Flags & ACPI_DB_CONSOLE_OUTPUT) 303 { 304 vfprintf (AcpiGbl_OutputFile, Fmt, Args); 305 } 306 } 307 308 309 /****************************************************************************** 310 * 311 * FUNCTION: AcpiOsGetLine 312 * 313 * PARAMETERS: Buffer - Where to return the command line 314 * BufferLength - Maximum length of Buffer 315 * BytesRead - Where the actual byte count is returned 316 * 317 * RETURN: Status and actual bytes read 318 * 319 * DESCRIPTION: Formatted input with argument list pointer 320 * 321 *****************************************************************************/ 322 323 ACPI_STATUS 324 AcpiOsGetLine ( 325 char *Buffer, 326 UINT32 BufferLength, 327 UINT32 *BytesRead) 328 { 329 UINT8 Temp; 330 UINT32 i; 331 332 333 for (i = 0; ; i++) 334 { 335 if (i >= BufferLength) 336 { 337 return (AE_BUFFER_OVERFLOW); 338 } 339 340 scanf ("%1c", &Temp); 341 if (!Temp || Temp == '\n') 342 { 343 break; 344 } 345 346 Buffer [i] = Temp; 347 } 348 349 /* Null terminate the buffer */ 350 351 Buffer [i] = 0; 352 353 /* Return the number of bytes in the string */ 354 355 if (BytesRead) 356 { 357 *BytesRead = i; 358 } 359 return (AE_OK); 360 } 361 362 363 /****************************************************************************** 364 * 365 * FUNCTION: AcpiOsMapMemory 366 * 367 * PARAMETERS: where - Physical address of memory to be mapped 368 * length - How much memory to map 369 * 370 * RETURN: Pointer to mapped memory. Null on error. 371 * 372 * DESCRIPTION: Map physical memory into caller's address space 373 * 374 *****************************************************************************/ 375 376 void * 377 AcpiOsMapMemory ( 378 ACPI_PHYSICAL_ADDRESS where, 379 ACPI_SIZE length) 380 { 381 382 return (ACPI_TO_POINTER ((ACPI_SIZE) where)); 383 } 384 385 386 /****************************************************************************** 387 * 388 * FUNCTION: AcpiOsUnmapMemory 389 * 390 * PARAMETERS: where - Logical address of memory to be unmapped 391 * length - How much memory to unmap 392 * 393 * RETURN: None. 394 * 395 * DESCRIPTION: Delete a previously created mapping. Where and Length must 396 * correspond to a previous mapping exactly. 397 * 398 *****************************************************************************/ 399 400 void 401 AcpiOsUnmapMemory ( 402 void *where, 403 ACPI_SIZE length) 404 { 405 406 return; 407 } 408 409 410 /****************************************************************************** 411 * 412 * FUNCTION: AcpiOsAllocate 413 * 414 * PARAMETERS: Size - Amount to allocate, in bytes 415 * 416 * RETURN: Pointer to the new allocation. Null on error. 417 * 418 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. 419 * 420 *****************************************************************************/ 421 422 void * 423 AcpiOsAllocate ( 424 ACPI_SIZE size) 425 { 426 void *Mem; 427 428 429 Mem = (void *) malloc ((size_t) size); 430 return (Mem); 431 } 432 433 434 /****************************************************************************** 435 * 436 * FUNCTION: AcpiOsFree 437 * 438 * PARAMETERS: mem - Pointer to previously allocated memory 439 * 440 * RETURN: None. 441 * 442 * DESCRIPTION: Free memory allocated via AcpiOsAllocate 443 * 444 *****************************************************************************/ 445 446 void 447 AcpiOsFree ( 448 void *mem) 449 { 450 451 free (mem); 452 } 453 454 455 #ifdef ACPI_SINGLE_THREADED 456 /****************************************************************************** 457 * 458 * FUNCTION: Semaphore stub functions 459 * 460 * DESCRIPTION: Stub functions used for single-thread applications that do 461 * not require semaphore synchronization. Full implementations 462 * of these functions appear after the stubs. 463 * 464 *****************************************************************************/ 465 466 ACPI_STATUS 467 AcpiOsCreateSemaphore ( 468 UINT32 MaxUnits, 469 UINT32 InitialUnits, 470 ACPI_HANDLE *OutHandle) 471 { 472 *OutHandle = (ACPI_HANDLE) 1; 473 return (AE_OK); 474 } 475 476 ACPI_STATUS 477 AcpiOsDeleteSemaphore ( 478 ACPI_HANDLE Handle) 479 { 480 return (AE_OK); 481 } 482 483 ACPI_STATUS 484 AcpiOsWaitSemaphore ( 485 ACPI_HANDLE Handle, 486 UINT32 Units, 487 UINT16 Timeout) 488 { 489 return (AE_OK); 490 } 491 492 ACPI_STATUS 493 AcpiOsSignalSemaphore ( 494 ACPI_HANDLE Handle, 495 UINT32 Units) 496 { 497 return (AE_OK); 498 } 499 500 #else 501 /****************************************************************************** 502 * 503 * FUNCTION: AcpiOsCreateSemaphore 504 * 505 * PARAMETERS: InitialUnits - Units to be assigned to the new semaphore 506 * OutHandle - Where a handle will be returned 507 * 508 * RETURN: Status 509 * 510 * DESCRIPTION: Create an OS semaphore 511 * 512 *****************************************************************************/ 513 514 ACPI_STATUS 515 AcpiOsCreateSemaphore ( 516 UINT32 MaxUnits, 517 UINT32 InitialUnits, 518 ACPI_HANDLE *OutHandle) 519 { 520 sem_t *Sem; 521 522 523 if (!OutHandle) 524 { 525 return (AE_BAD_PARAMETER); 526 } 527 528 #ifdef __APPLE__ 529 { 530 char *SemaphoreName = tmpnam (NULL); 531 532 Sem = sem_open (SemaphoreName, O_EXCL|O_CREAT, 0755, InitialUnits); 533 if (!Sem) 534 { 535 return (AE_NO_MEMORY); 536 } 537 sem_unlink (SemaphoreName); /* This just deletes the name */ 538 } 539 540 #else 541 Sem = AcpiOsAllocate (sizeof (sem_t)); 542 if (!Sem) 543 { 544 return (AE_NO_MEMORY); 545 } 546 547 if (sem_init (Sem, 0, InitialUnits) == -1) 548 { 549 AcpiOsFree (Sem); 550 return (AE_BAD_PARAMETER); 551 } 552 #endif 553 554 *OutHandle = (ACPI_HANDLE) Sem; 555 return (AE_OK); 556 } 557 558 559 /****************************************************************************** 560 * 561 * FUNCTION: AcpiOsDeleteSemaphore 562 * 563 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 564 * 565 * RETURN: Status 566 * 567 * DESCRIPTION: Delete an OS semaphore 568 * 569 *****************************************************************************/ 570 571 ACPI_STATUS 572 AcpiOsDeleteSemaphore ( 573 ACPI_HANDLE Handle) 574 { 575 sem_t *Sem = (sem_t *) Handle; 576 577 578 if (!Sem) 579 { 580 return (AE_BAD_PARAMETER); 581 } 582 583 if (sem_destroy (Sem) == -1) 584 { 585 return (AE_BAD_PARAMETER); 586 } 587 588 return (AE_OK); 589 } 590 591 592 /****************************************************************************** 593 * 594 * FUNCTION: AcpiOsWaitSemaphore 595 * 596 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 597 * Units - How many units to wait for 598 * Timeout - How long to wait 599 * 600 * RETURN: Status 601 * 602 * DESCRIPTION: Wait for units 603 * 604 *****************************************************************************/ 605 606 ACPI_STATUS 607 AcpiOsWaitSemaphore ( 608 ACPI_HANDLE Handle, 609 UINT32 Units, 610 UINT16 Timeout) 611 { 612 ACPI_STATUS Status = AE_OK; 613 sem_t *Sem = (sem_t *) Handle; 614 struct timespec T; 615 616 617 if (!Sem) 618 { 619 return (AE_BAD_PARAMETER); 620 } 621 622 switch (Timeout) 623 { 624 /* 625 * No Wait: 626 * -------- 627 * A zero timeout value indicates that we shouldn't wait - just 628 * acquire the semaphore if available otherwise return AE_TIME 629 * (a.k.a. 'would block'). 630 */ 631 case 0: 632 633 if (sem_trywait(Sem) == -1) 634 { 635 Status = (AE_TIME); 636 } 637 break; 638 639 /* Wait Indefinitely */ 640 641 case ACPI_WAIT_FOREVER: 642 643 if (sem_wait (Sem)) 644 { 645 Status = (AE_TIME); 646 } 647 break; 648 649 /* Wait with Timeout */ 650 651 default: 652 653 T.tv_sec = Timeout / 1000; 654 T.tv_nsec = (Timeout - (T.tv_sec * 1000)) * 1000000; 655 656 #ifdef ACPI_USE_ALTERNATE_TIMEOUT 657 /* 658 * Alternate timeout mechanism for environments where 659 * sem_timedwait is not available or does not work properly. 660 */ 661 while (Timeout) 662 { 663 if (sem_trywait (Sem) == 0) 664 { 665 /* Got the semaphore */ 666 return (AE_OK); 667 } 668 usleep (1000); /* one millisecond */ 669 Timeout--; 670 } 671 Status = (AE_TIME); 672 #else 673 674 if (sem_timedwait (Sem, &T)) 675 { 676 Status = (AE_TIME); 677 } 678 #endif 679 680 break; 681 } 682 683 return (Status); 684 } 685 686 687 /****************************************************************************** 688 * 689 * FUNCTION: AcpiOsSignalSemaphore 690 * 691 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 692 * Units - Number of units to send 693 * 694 * RETURN: Status 695 * 696 * DESCRIPTION: Send units 697 * 698 *****************************************************************************/ 699 700 ACPI_STATUS 701 AcpiOsSignalSemaphore ( 702 ACPI_HANDLE Handle, 703 UINT32 Units) 704 { 705 sem_t *Sem = (sem_t *)Handle; 706 707 708 if (!Sem) 709 { 710 return (AE_BAD_PARAMETER); 711 } 712 713 if (sem_post (Sem) == -1) 714 { 715 return (AE_LIMIT); 716 } 717 718 return (AE_OK); 719 } 720 721 #endif /* ACPI_SINGLE_THREADED */ 722 723 724 /****************************************************************************** 725 * 726 * FUNCTION: Spinlock interfaces 727 * 728 * DESCRIPTION: Map these interfaces to semaphore interfaces 729 * 730 *****************************************************************************/ 731 732 ACPI_STATUS 733 AcpiOsCreateLock ( 734 ACPI_SPINLOCK *OutHandle) 735 { 736 737 return (AcpiOsCreateSemaphore (1, 1, OutHandle)); 738 } 739 740 741 void 742 AcpiOsDeleteLock ( 743 ACPI_SPINLOCK Handle) 744 { 745 AcpiOsDeleteSemaphore (Handle); 746 } 747 748 749 ACPI_CPU_FLAGS 750 AcpiOsAcquireLock ( 751 ACPI_HANDLE Handle) 752 { 753 AcpiOsWaitSemaphore (Handle, 1, 0xFFFF); 754 return (0); 755 } 756 757 758 void 759 AcpiOsReleaseLock ( 760 ACPI_SPINLOCK Handle, 761 ACPI_CPU_FLAGS Flags) 762 { 763 AcpiOsSignalSemaphore (Handle, 1); 764 } 765 766 767 /****************************************************************************** 768 * 769 * FUNCTION: AcpiOsInstallInterruptHandler 770 * 771 * PARAMETERS: InterruptNumber - Level handler should respond to. 772 * Isr - Address of the ACPI interrupt handler 773 * ExceptPtr - Where status is returned 774 * 775 * RETURN: Handle to the newly installed handler. 776 * 777 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI 778 * OS-independent handler. 779 * 780 *****************************************************************************/ 781 782 UINT32 783 AcpiOsInstallInterruptHandler ( 784 UINT32 InterruptNumber, 785 ACPI_OSD_HANDLER ServiceRoutine, 786 void *Context) 787 { 788 789 return (AE_OK); 790 } 791 792 793 /****************************************************************************** 794 * 795 * FUNCTION: AcpiOsRemoveInterruptHandler 796 * 797 * PARAMETERS: Handle - Returned when handler was installed 798 * 799 * RETURN: Status 800 * 801 * DESCRIPTION: Uninstalls an interrupt handler. 802 * 803 *****************************************************************************/ 804 805 ACPI_STATUS 806 AcpiOsRemoveInterruptHandler ( 807 UINT32 InterruptNumber, 808 ACPI_OSD_HANDLER ServiceRoutine) 809 { 810 811 return (AE_OK); 812 } 813 814 815 /****************************************************************************** 816 * 817 * FUNCTION: AcpiOsStall 818 * 819 * PARAMETERS: microseconds - Time to sleep 820 * 821 * RETURN: Blocks until sleep is completed. 822 * 823 * DESCRIPTION: Sleep at microsecond granularity 824 * 825 *****************************************************************************/ 826 827 void 828 AcpiOsStall ( 829 UINT32 microseconds) 830 { 831 832 if (microseconds) 833 { 834 usleep (microseconds); 835 } 836 } 837 838 839 /****************************************************************************** 840 * 841 * FUNCTION: AcpiOsSleep 842 * 843 * PARAMETERS: milliseconds - Time to sleep 844 * 845 * RETURN: Blocks until sleep is completed. 846 * 847 * DESCRIPTION: Sleep at millisecond granularity 848 * 849 *****************************************************************************/ 850 851 void 852 AcpiOsSleep ( 853 UINT64 milliseconds) 854 { 855 856 sleep (milliseconds / 1000); /* Sleep for whole seconds */ 857 858 /* 859 * Arg to usleep() must be less than 1,000,000 (1 second) 860 */ 861 usleep ((milliseconds % 1000) * 1000); /* Sleep for remaining usecs */ 862 } 863 864 865 /****************************************************************************** 866 * 867 * FUNCTION: AcpiOsGetTimer 868 * 869 * PARAMETERS: None 870 * 871 * RETURN: Current time in 100 nanosecond units 872 * 873 * DESCRIPTION: Get the current system time 874 * 875 *****************************************************************************/ 876 877 UINT64 878 AcpiOsGetTimer ( 879 void) 880 { 881 struct timeval time; 882 883 884 gettimeofday (&time, NULL); 885 886 /* Seconds * 10^7 = 100ns(10^-7), Microseconds(10^-6) * 10^1 = 100ns */ 887 888 return (((UINT64) time.tv_sec * 10000000) + ((UINT64) time.tv_usec * 10)); 889 } 890 891 892 /****************************************************************************** 893 * 894 * FUNCTION: AcpiOsReadPciConfiguration 895 * 896 * PARAMETERS: PciId - Seg/Bus/Dev 897 * Register - Device Register 898 * Value - Buffer where value is placed 899 * Width - Number of bits 900 * 901 * RETURN: Status 902 * 903 * DESCRIPTION: Read data from PCI configuration space 904 * 905 *****************************************************************************/ 906 907 ACPI_STATUS 908 AcpiOsReadPciConfiguration ( 909 ACPI_PCI_ID *PciId, 910 UINT32 Register, 911 UINT64 *Value, 912 UINT32 Width) 913 { 914 915 return (AE_OK); 916 } 917 918 919 /****************************************************************************** 920 * 921 * FUNCTION: AcpiOsWritePciConfiguration 922 * 923 * PARAMETERS: PciId - Seg/Bus/Dev 924 * Register - Device Register 925 * Value - Value to be written 926 * Width - Number of bits 927 * 928 * RETURN: Status. 929 * 930 * DESCRIPTION: Write data to PCI configuration space 931 * 932 *****************************************************************************/ 933 934 ACPI_STATUS 935 AcpiOsWritePciConfiguration ( 936 ACPI_PCI_ID *PciId, 937 UINT32 Register, 938 UINT64 Value, 939 UINT32 Width) 940 { 941 942 return (AE_OK); 943 } 944 945 946 /****************************************************************************** 947 * 948 * FUNCTION: AcpiOsReadPort 949 * 950 * PARAMETERS: Address - Address of I/O port/register to read 951 * Value - Where value is placed 952 * Width - Number of bits 953 * 954 * RETURN: Value read from port 955 * 956 * DESCRIPTION: Read data from an I/O port or register 957 * 958 *****************************************************************************/ 959 960 ACPI_STATUS 961 AcpiOsReadPort ( 962 ACPI_IO_ADDRESS Address, 963 UINT32 *Value, 964 UINT32 Width) 965 { 966 967 switch (Width) 968 { 969 case 8: 970 *Value = 0xFF; 971 break; 972 973 case 16: 974 *Value = 0xFFFF; 975 break; 976 977 case 32: 978 *Value = 0xFFFFFFFF; 979 break; 980 981 default: 982 return (AE_BAD_PARAMETER); 983 } 984 985 return (AE_OK); 986 } 987 988 989 /****************************************************************************** 990 * 991 * FUNCTION: AcpiOsWritePort 992 * 993 * PARAMETERS: Address - Address of I/O port/register to write 994 * Value - Value to write 995 * Width - Number of bits 996 * 997 * RETURN: None 998 * 999 * DESCRIPTION: Write data to an I/O port or register 1000 * 1001 *****************************************************************************/ 1002 1003 ACPI_STATUS 1004 AcpiOsWritePort ( 1005 ACPI_IO_ADDRESS Address, 1006 UINT32 Value, 1007 UINT32 Width) 1008 { 1009 1010 return (AE_OK); 1011 } 1012 1013 1014 /****************************************************************************** 1015 * 1016 * FUNCTION: AcpiOsReadMemory 1017 * 1018 * PARAMETERS: Address - Physical Memory Address to read 1019 * Value - Where value is placed 1020 * Width - Number of bits 1021 * 1022 * RETURN: Value read from physical memory address 1023 * 1024 * DESCRIPTION: Read data from a physical memory address 1025 * 1026 *****************************************************************************/ 1027 1028 ACPI_STATUS 1029 AcpiOsReadMemory ( 1030 ACPI_PHYSICAL_ADDRESS Address, 1031 UINT32 *Value, 1032 UINT32 Width) 1033 { 1034 1035 switch (Width) 1036 { 1037 case 8: 1038 case 16: 1039 case 32: 1040 *Value = 0; 1041 break; 1042 1043 default: 1044 return (AE_BAD_PARAMETER); 1045 } 1046 return (AE_OK); 1047 } 1048 1049 1050 /****************************************************************************** 1051 * 1052 * FUNCTION: AcpiOsWriteMemory 1053 * 1054 * PARAMETERS: Address - Physical Memory Address to write 1055 * Value - Value to write 1056 * Width - Number of bits 1057 * 1058 * RETURN: None 1059 * 1060 * DESCRIPTION: Write data to a physical memory address 1061 * 1062 *****************************************************************************/ 1063 1064 ACPI_STATUS 1065 AcpiOsWriteMemory ( 1066 ACPI_PHYSICAL_ADDRESS Address, 1067 UINT32 Value, 1068 UINT32 Width) 1069 { 1070 1071 return (AE_OK); 1072 } 1073 1074 1075 /****************************************************************************** 1076 * 1077 * FUNCTION: AcpiOsReadable 1078 * 1079 * PARAMETERS: Pointer - Area to be verified 1080 * Length - Size of area 1081 * 1082 * RETURN: TRUE if readable for entire length 1083 * 1084 * DESCRIPTION: Verify that a pointer is valid for reading 1085 * 1086 *****************************************************************************/ 1087 1088 BOOLEAN 1089 AcpiOsReadable ( 1090 void *Pointer, 1091 ACPI_SIZE Length) 1092 { 1093 1094 return (TRUE); 1095 } 1096 1097 1098 /****************************************************************************** 1099 * 1100 * FUNCTION: AcpiOsWritable 1101 * 1102 * PARAMETERS: Pointer - Area to be verified 1103 * Length - Size of area 1104 * 1105 * RETURN: TRUE if writable for entire length 1106 * 1107 * DESCRIPTION: Verify that a pointer is valid for writing 1108 * 1109 *****************************************************************************/ 1110 1111 BOOLEAN 1112 AcpiOsWritable ( 1113 void *Pointer, 1114 ACPI_SIZE Length) 1115 { 1116 1117 return (TRUE); 1118 } 1119 1120 1121 /****************************************************************************** 1122 * 1123 * FUNCTION: AcpiOsSignal 1124 * 1125 * PARAMETERS: Function - ACPI CA signal function code 1126 * Info - Pointer to function-dependent structure 1127 * 1128 * RETURN: Status 1129 * 1130 * DESCRIPTION: Miscellaneous functions. Example implementation only. 1131 * 1132 *****************************************************************************/ 1133 1134 ACPI_STATUS 1135 AcpiOsSignal ( 1136 UINT32 Function, 1137 void *Info) 1138 { 1139 1140 switch (Function) 1141 { 1142 case ACPI_SIGNAL_FATAL: 1143 break; 1144 1145 case ACPI_SIGNAL_BREAKPOINT: 1146 break; 1147 1148 default: 1149 break; 1150 } 1151 1152 return (AE_OK); 1153 } 1154 1155 /* Optional multi-thread support */ 1156 1157 #ifndef ACPI_SINGLE_THREADED 1158 /****************************************************************************** 1159 * 1160 * FUNCTION: AcpiOsGetThreadId 1161 * 1162 * PARAMETERS: None 1163 * 1164 * RETURN: Id of the running thread 1165 * 1166 * DESCRIPTION: Get the ID of the current (running) thread 1167 * 1168 *****************************************************************************/ 1169 1170 ACPI_THREAD_ID 1171 AcpiOsGetThreadId ( 1172 void) 1173 { 1174 pthread_t thread; 1175 1176 1177 thread = pthread_self(); 1178 return (ACPI_CAST_PTHREAD_T (thread)); 1179 } 1180 1181 1182 /****************************************************************************** 1183 * 1184 * FUNCTION: AcpiOsExecute 1185 * 1186 * PARAMETERS: Type - Type of execution 1187 * Function - Address of the function to execute 1188 * Context - Passed as a parameter to the function 1189 * 1190 * RETURN: Status. 1191 * 1192 * DESCRIPTION: Execute a new thread 1193 * 1194 *****************************************************************************/ 1195 1196 ACPI_STATUS 1197 AcpiOsExecute ( 1198 ACPI_EXECUTE_TYPE Type, 1199 ACPI_OSD_EXEC_CALLBACK Function, 1200 void *Context) 1201 { 1202 pthread_t thread; 1203 int ret; 1204 1205 1206 ret = pthread_create (&thread, NULL, (PTHREAD_CALLBACK) Function, Context); 1207 if (ret) 1208 { 1209 AcpiOsPrintf("Create thread failed"); 1210 } 1211 return (0); 1212 } 1213 1214 #endif /* ACPI_SINGLE_THREADED */ 1215