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 <stdio.h> 52 #include <stdlib.h> 53 #include <stdarg.h> 54 #include <unistd.h> 55 #include <sys/time.h> 56 #include <semaphore.h> 57 #include <pthread.h> 58 #include <errno.h> 59 60 #include "acpi.h" 61 #include "accommon.h" 62 #include "amlcode.h" 63 #include "acparser.h" 64 #include "acdebug.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 INT32 Count = 0; 281 UINT8 Flags; 282 283 284 Flags = AcpiGbl_DbOutputFlags; 285 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT) 286 { 287 /* Output is directable to either a file (if open) or the console */ 288 289 if (AcpiGbl_DebugFile) 290 { 291 /* Output file is open, send the output there */ 292 293 Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args); 294 } 295 else 296 { 297 /* No redirection, send output to console (once only!) */ 298 299 Flags |= ACPI_DB_CONSOLE_OUTPUT; 300 } 301 } 302 303 if (Flags & ACPI_DB_CONSOLE_OUTPUT) 304 { 305 Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args); 306 } 307 } 308 309 310 /****************************************************************************** 311 * 312 * FUNCTION: AcpiOsGetLine 313 * 314 * PARAMETERS: fmt - Standard printf format 315 * args - Argument list 316 * 317 * RETURN: Actual bytes read 318 * 319 * DESCRIPTION: Formatted input with argument list pointer 320 * 321 *****************************************************************************/ 322 323 UINT32 324 AcpiOsGetLine ( 325 char *Buffer) 326 { 327 UINT8 Temp; 328 UINT32 i; 329 330 331 for (i = 0; ; i++) 332 { 333 scanf ("%1c", &Temp); 334 if (!Temp || Temp == '\n') 335 { 336 break; 337 } 338 339 Buffer [i] = Temp; 340 } 341 342 /* Null terminate the buffer */ 343 344 Buffer [i] = 0; 345 346 /* Return the number of bytes in the string */ 347 348 return (i); 349 } 350 351 352 /****************************************************************************** 353 * 354 * FUNCTION: AcpiOsMapMemory 355 * 356 * PARAMETERS: where - Physical address of memory to be mapped 357 * length - How much memory to map 358 * 359 * RETURN: Pointer to mapped memory. Null on error. 360 * 361 * DESCRIPTION: Map physical memory into caller's address space 362 * 363 *****************************************************************************/ 364 365 void * 366 AcpiOsMapMemory ( 367 ACPI_PHYSICAL_ADDRESS where, 368 ACPI_SIZE length) 369 { 370 371 return (ACPI_TO_POINTER ((ACPI_SIZE) where)); 372 } 373 374 375 /****************************************************************************** 376 * 377 * FUNCTION: AcpiOsUnmapMemory 378 * 379 * PARAMETERS: where - Logical address of memory to be unmapped 380 * length - How much memory to unmap 381 * 382 * RETURN: None. 383 * 384 * DESCRIPTION: Delete a previously created mapping. Where and Length must 385 * correspond to a previous mapping exactly. 386 * 387 *****************************************************************************/ 388 389 void 390 AcpiOsUnmapMemory ( 391 void *where, 392 ACPI_SIZE length) 393 { 394 395 return; 396 } 397 398 399 /****************************************************************************** 400 * 401 * FUNCTION: AcpiOsAllocate 402 * 403 * PARAMETERS: Size - Amount to allocate, in bytes 404 * 405 * RETURN: Pointer to the new allocation. Null on error. 406 * 407 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. 408 * 409 *****************************************************************************/ 410 411 void * 412 AcpiOsAllocate ( 413 ACPI_SIZE size) 414 { 415 void *Mem; 416 417 418 Mem = (void *) malloc ((size_t) size); 419 return (Mem); 420 } 421 422 423 /****************************************************************************** 424 * 425 * FUNCTION: AcpiOsFree 426 * 427 * PARAMETERS: mem - Pointer to previously allocated memory 428 * 429 * RETURN: None. 430 * 431 * DESCRIPTION: Free memory allocated via AcpiOsAllocate 432 * 433 *****************************************************************************/ 434 435 void 436 AcpiOsFree ( 437 void *mem) 438 { 439 440 free (mem); 441 } 442 443 444 #ifdef ACPI_SINGLE_THREADED 445 /****************************************************************************** 446 * 447 * FUNCTION: Semaphore stub functions 448 * 449 * DESCRIPTION: Stub functions used for single-thread applications that do 450 * not require semaphore synchronization. Full implementations 451 * of these functions appear after the stubs. 452 * 453 *****************************************************************************/ 454 455 ACPI_STATUS 456 AcpiOsCreateSemaphore ( 457 UINT32 MaxUnits, 458 UINT32 InitialUnits, 459 ACPI_HANDLE *OutHandle) 460 { 461 *OutHandle = (ACPI_HANDLE) 1; 462 return (AE_OK); 463 } 464 465 ACPI_STATUS 466 AcpiOsDeleteSemaphore ( 467 ACPI_HANDLE Handle) 468 { 469 return (AE_OK); 470 } 471 472 ACPI_STATUS 473 AcpiOsWaitSemaphore ( 474 ACPI_HANDLE Handle, 475 UINT32 Units, 476 UINT16 Timeout) 477 { 478 return (AE_OK); 479 } 480 481 ACPI_STATUS 482 AcpiOsSignalSemaphore ( 483 ACPI_HANDLE Handle, 484 UINT32 Units) 485 { 486 return (AE_OK); 487 } 488 489 #else 490 /****************************************************************************** 491 * 492 * FUNCTION: AcpiOsCreateSemaphore 493 * 494 * PARAMETERS: InitialUnits - Units to be assigned to the new semaphore 495 * OutHandle - Where a handle will be returned 496 * 497 * RETURN: Status 498 * 499 * DESCRIPTION: Create an OS semaphore 500 * 501 *****************************************************************************/ 502 503 ACPI_STATUS 504 AcpiOsCreateSemaphore ( 505 UINT32 MaxUnits, 506 UINT32 InitialUnits, 507 ACPI_HANDLE *OutHandle) 508 { 509 sem_t *Sem; 510 511 512 if (!OutHandle) 513 { 514 return (AE_BAD_PARAMETER); 515 } 516 517 #ifdef __APPLE__ 518 { 519 char *SemaphoreName = tmpnam (NULL); 520 521 Sem = sem_open (SemaphoreName, O_EXCL|O_CREAT, 0755, InitialUnits); 522 if (!Sem) 523 { 524 return (AE_NO_MEMORY); 525 } 526 sem_unlink (SemaphoreName); /* This just deletes the name */ 527 } 528 529 #else 530 Sem = AcpiOsAllocate (sizeof (sem_t)); 531 if (!Sem) 532 { 533 return (AE_NO_MEMORY); 534 } 535 536 if (sem_init (Sem, 0, InitialUnits) == -1) 537 { 538 AcpiOsFree (Sem); 539 return (AE_BAD_PARAMETER); 540 } 541 #endif 542 543 *OutHandle = (ACPI_HANDLE) Sem; 544 return (AE_OK); 545 } 546 547 548 /****************************************************************************** 549 * 550 * FUNCTION: AcpiOsDeleteSemaphore 551 * 552 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 553 * 554 * RETURN: Status 555 * 556 * DESCRIPTION: Delete an OS semaphore 557 * 558 *****************************************************************************/ 559 560 ACPI_STATUS 561 AcpiOsDeleteSemaphore ( 562 ACPI_HANDLE Handle) 563 { 564 sem_t *Sem = (sem_t *) Handle; 565 566 567 if (!Sem) 568 { 569 return (AE_BAD_PARAMETER); 570 } 571 572 if (sem_destroy (Sem) == -1) 573 { 574 return (AE_BAD_PARAMETER); 575 } 576 577 return (AE_OK); 578 } 579 580 581 /****************************************************************************** 582 * 583 * FUNCTION: AcpiOsWaitSemaphore 584 * 585 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 586 * Units - How many units to wait for 587 * Timeout - How long to wait 588 * 589 * RETURN: Status 590 * 591 * DESCRIPTION: Wait for units 592 * 593 *****************************************************************************/ 594 595 ACPI_STATUS 596 AcpiOsWaitSemaphore ( 597 ACPI_HANDLE Handle, 598 UINT32 Units, 599 UINT16 Timeout) 600 { 601 ACPI_STATUS Status = AE_OK; 602 sem_t *Sem = (sem_t *) Handle; 603 struct timespec T; 604 605 606 if (!Sem) 607 { 608 return (AE_BAD_PARAMETER); 609 } 610 611 switch (Timeout) 612 { 613 /* 614 * No Wait: 615 * -------- 616 * A zero timeout value indicates that we shouldn't wait - just 617 * acquire the semaphore if available otherwise return AE_TIME 618 * (a.k.a. 'would block'). 619 */ 620 case 0: 621 622 if (sem_trywait(Sem) == -1) 623 { 624 Status = (AE_TIME); 625 } 626 break; 627 628 /* Wait Indefinitely */ 629 630 case ACPI_WAIT_FOREVER: 631 632 if (sem_wait (Sem)) 633 { 634 Status = (AE_TIME); 635 } 636 break; 637 638 /* Wait with Timeout */ 639 640 default: 641 642 T.tv_sec = Timeout / 1000; 643 T.tv_nsec = (Timeout - (T.tv_sec * 1000)) * 1000000; 644 645 #ifdef ACPI_USE_ALTERNATE_TIMEOUT 646 /* 647 * Alternate timeout mechanism for environments where 648 * sem_timedwait is not available or does not work properly. 649 */ 650 while (Timeout) 651 { 652 if (sem_trywait (Sem) == 0) 653 { 654 /* Got the semaphore */ 655 return (AE_OK); 656 } 657 usleep (1000); /* one millisecond */ 658 Timeout--; 659 } 660 Status = (AE_TIME); 661 #else 662 663 if (sem_timedwait (Sem, &T)) 664 { 665 Status = (AE_TIME); 666 } 667 #endif 668 669 break; 670 } 671 672 return (Status); 673 } 674 675 676 /****************************************************************************** 677 * 678 * FUNCTION: AcpiOsSignalSemaphore 679 * 680 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 681 * Units - Number of units to send 682 * 683 * RETURN: Status 684 * 685 * DESCRIPTION: Send units 686 * 687 *****************************************************************************/ 688 689 ACPI_STATUS 690 AcpiOsSignalSemaphore ( 691 ACPI_HANDLE Handle, 692 UINT32 Units) 693 { 694 sem_t *Sem = (sem_t *)Handle; 695 696 697 if (!Sem) 698 { 699 return (AE_BAD_PARAMETER); 700 } 701 702 if (sem_post (Sem) == -1) 703 { 704 return (AE_LIMIT); 705 } 706 707 return (AE_OK); 708 } 709 710 #endif /* ACPI_SINGLE_THREADED */ 711 712 713 /****************************************************************************** 714 * 715 * FUNCTION: Spinlock interfaces 716 * 717 * DESCRIPTION: Map these interfaces to semaphore interfaces 718 * 719 *****************************************************************************/ 720 721 ACPI_STATUS 722 AcpiOsCreateLock ( 723 ACPI_SPINLOCK *OutHandle) 724 { 725 726 return (AcpiOsCreateSemaphore (1, 1, OutHandle)); 727 } 728 729 730 void 731 AcpiOsDeleteLock ( 732 ACPI_SPINLOCK Handle) 733 { 734 AcpiOsDeleteSemaphore (Handle); 735 } 736 737 738 ACPI_CPU_FLAGS 739 AcpiOsAcquireLock ( 740 ACPI_HANDLE Handle) 741 { 742 AcpiOsWaitSemaphore (Handle, 1, 0xFFFF); 743 return (0); 744 } 745 746 747 void 748 AcpiOsReleaseLock ( 749 ACPI_SPINLOCK Handle, 750 ACPI_CPU_FLAGS Flags) 751 { 752 AcpiOsSignalSemaphore (Handle, 1); 753 } 754 755 756 /****************************************************************************** 757 * 758 * FUNCTION: AcpiOsInstallInterruptHandler 759 * 760 * PARAMETERS: InterruptNumber - Level handler should respond to. 761 * Isr - Address of the ACPI interrupt handler 762 * ExceptPtr - Where status is returned 763 * 764 * RETURN: Handle to the newly installed handler. 765 * 766 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI 767 * OS-independent handler. 768 * 769 *****************************************************************************/ 770 771 UINT32 772 AcpiOsInstallInterruptHandler ( 773 UINT32 InterruptNumber, 774 ACPI_OSD_HANDLER ServiceRoutine, 775 void *Context) 776 { 777 778 return (AE_OK); 779 } 780 781 782 /****************************************************************************** 783 * 784 * FUNCTION: AcpiOsRemoveInterruptHandler 785 * 786 * PARAMETERS: Handle - Returned when handler was installed 787 * 788 * RETURN: Status 789 * 790 * DESCRIPTION: Uninstalls an interrupt handler. 791 * 792 *****************************************************************************/ 793 794 ACPI_STATUS 795 AcpiOsRemoveInterruptHandler ( 796 UINT32 InterruptNumber, 797 ACPI_OSD_HANDLER ServiceRoutine) 798 { 799 800 return (AE_OK); 801 } 802 803 804 /****************************************************************************** 805 * 806 * FUNCTION: AcpiOsExecute 807 * 808 * PARAMETERS: Type - Type of execution 809 * Function - Address of the function to execute 810 * Context - Passed as a parameter to the function 811 * 812 * RETURN: Status. 813 * 814 * DESCRIPTION: Execute a new thread 815 * 816 *****************************************************************************/ 817 818 ACPI_STATUS 819 AcpiOsExecute ( 820 ACPI_EXECUTE_TYPE Type, 821 ACPI_OSD_EXEC_CALLBACK Function, 822 void *Context) 823 { 824 pthread_t thread; 825 int ret; 826 827 828 ret = pthread_create (&thread, NULL, (PTHREAD_CALLBACK) Function, Context); 829 if (ret) 830 { 831 AcpiOsPrintf("Create thread failed"); 832 } 833 return (0); 834 } 835 836 837 /****************************************************************************** 838 * 839 * FUNCTION: AcpiOsStall 840 * 841 * PARAMETERS: microseconds - Time to sleep 842 * 843 * RETURN: Blocks until sleep is completed. 844 * 845 * DESCRIPTION: Sleep at microsecond granularity 846 * 847 *****************************************************************************/ 848 849 void 850 AcpiOsStall ( 851 UINT32 microseconds) 852 { 853 854 if (microseconds) 855 { 856 usleep (microseconds); 857 } 858 } 859 860 861 /****************************************************************************** 862 * 863 * FUNCTION: AcpiOsSleep 864 * 865 * PARAMETERS: milliseconds - Time to sleep 866 * 867 * RETURN: Blocks until sleep is completed. 868 * 869 * DESCRIPTION: Sleep at millisecond granularity 870 * 871 *****************************************************************************/ 872 873 void 874 AcpiOsSleep ( 875 UINT64 milliseconds) 876 { 877 878 sleep (milliseconds / 1000); /* Sleep for whole seconds */ 879 880 /* 881 * Arg to usleep() must be less than 1,000,000 (1 second) 882 */ 883 usleep ((milliseconds % 1000) * 1000); /* Sleep for remaining usecs */ 884 } 885 886 887 /****************************************************************************** 888 * 889 * FUNCTION: AcpiOsGetTimer 890 * 891 * PARAMETERS: None 892 * 893 * RETURN: Current time in 100 nanosecond units 894 * 895 * DESCRIPTION: Get the current system time 896 * 897 *****************************************************************************/ 898 899 UINT64 900 AcpiOsGetTimer ( 901 void) 902 { 903 struct timeval time; 904 905 906 gettimeofday (&time, NULL); 907 908 /* Seconds * 10^7 = 100ns(10^-7), Microseconds(10^-6) * 10^1 = 100ns */ 909 910 return (((UINT64) time.tv_sec * 10000000) + ((UINT64) time.tv_usec * 10)); 911 } 912 913 914 /****************************************************************************** 915 * 916 * FUNCTION: AcpiOsReadPciConfiguration 917 * 918 * PARAMETERS: PciId - Seg/Bus/Dev 919 * Register - Device Register 920 * Value - Buffer where value is placed 921 * Width - Number of bits 922 * 923 * RETURN: Status 924 * 925 * DESCRIPTION: Read data from PCI configuration space 926 * 927 *****************************************************************************/ 928 929 ACPI_STATUS 930 AcpiOsReadPciConfiguration ( 931 ACPI_PCI_ID *PciId, 932 UINT32 Register, 933 UINT64 *Value, 934 UINT32 Width) 935 { 936 937 return (AE_OK); 938 } 939 940 941 /****************************************************************************** 942 * 943 * FUNCTION: AcpiOsWritePciConfiguration 944 * 945 * PARAMETERS: PciId - Seg/Bus/Dev 946 * Register - Device Register 947 * Value - Value to be written 948 * Width - Number of bits 949 * 950 * RETURN: Status. 951 * 952 * DESCRIPTION: Write data to PCI configuration space 953 * 954 *****************************************************************************/ 955 956 ACPI_STATUS 957 AcpiOsWritePciConfiguration ( 958 ACPI_PCI_ID *PciId, 959 UINT32 Register, 960 UINT64 Value, 961 UINT32 Width) 962 { 963 964 return (AE_OK); 965 } 966 967 968 /****************************************************************************** 969 * 970 * FUNCTION: AcpiOsReadPort 971 * 972 * PARAMETERS: Address - Address of I/O port/register to read 973 * Value - Where value is placed 974 * Width - Number of bits 975 * 976 * RETURN: Value read from port 977 * 978 * DESCRIPTION: Read data from an I/O port or register 979 * 980 *****************************************************************************/ 981 982 ACPI_STATUS 983 AcpiOsReadPort ( 984 ACPI_IO_ADDRESS Address, 985 UINT32 *Value, 986 UINT32 Width) 987 { 988 989 switch (Width) 990 { 991 case 8: 992 *Value = 0xFF; 993 break; 994 995 case 16: 996 *Value = 0xFFFF; 997 break; 998 999 case 32: 1000 *Value = 0xFFFFFFFF; 1001 break; 1002 1003 default: 1004 return (AE_BAD_PARAMETER); 1005 } 1006 1007 return (AE_OK); 1008 } 1009 1010 1011 /****************************************************************************** 1012 * 1013 * FUNCTION: AcpiOsWritePort 1014 * 1015 * PARAMETERS: Address - Address of I/O port/register to write 1016 * Value - Value to write 1017 * Width - Number of bits 1018 * 1019 * RETURN: None 1020 * 1021 * DESCRIPTION: Write data to an I/O port or register 1022 * 1023 *****************************************************************************/ 1024 1025 ACPI_STATUS 1026 AcpiOsWritePort ( 1027 ACPI_IO_ADDRESS Address, 1028 UINT32 Value, 1029 UINT32 Width) 1030 { 1031 1032 return (AE_OK); 1033 } 1034 1035 1036 /****************************************************************************** 1037 * 1038 * FUNCTION: AcpiOsReadMemory 1039 * 1040 * PARAMETERS: Address - Physical Memory Address to read 1041 * Value - Where value is placed 1042 * Width - Number of bits 1043 * 1044 * RETURN: Value read from physical memory address 1045 * 1046 * DESCRIPTION: Read data from a physical memory address 1047 * 1048 *****************************************************************************/ 1049 1050 ACPI_STATUS 1051 AcpiOsReadMemory ( 1052 ACPI_PHYSICAL_ADDRESS Address, 1053 UINT32 *Value, 1054 UINT32 Width) 1055 { 1056 1057 switch (Width) 1058 { 1059 case 8: 1060 case 16: 1061 case 32: 1062 *Value = 0; 1063 break; 1064 1065 default: 1066 return (AE_BAD_PARAMETER); 1067 } 1068 return (AE_OK); 1069 } 1070 1071 1072 /****************************************************************************** 1073 * 1074 * FUNCTION: AcpiOsWriteMemory 1075 * 1076 * PARAMETERS: Address - Physical Memory Address to write 1077 * Value - Value to write 1078 * Width - Number of bits 1079 * 1080 * RETURN: None 1081 * 1082 * DESCRIPTION: Write data to a physical memory address 1083 * 1084 *****************************************************************************/ 1085 1086 ACPI_STATUS 1087 AcpiOsWriteMemory ( 1088 ACPI_PHYSICAL_ADDRESS Address, 1089 UINT32 Value, 1090 UINT32 Width) 1091 { 1092 1093 return (AE_OK); 1094 } 1095 1096 1097 /****************************************************************************** 1098 * 1099 * FUNCTION: AcpiOsReadable 1100 * 1101 * PARAMETERS: Pointer - Area to be verified 1102 * Length - Size of area 1103 * 1104 * RETURN: TRUE if readable for entire length 1105 * 1106 * DESCRIPTION: Verify that a pointer is valid for reading 1107 * 1108 *****************************************************************************/ 1109 1110 BOOLEAN 1111 AcpiOsReadable ( 1112 void *Pointer, 1113 ACPI_SIZE Length) 1114 { 1115 1116 return (TRUE); 1117 } 1118 1119 1120 /****************************************************************************** 1121 * 1122 * FUNCTION: AcpiOsWritable 1123 * 1124 * PARAMETERS: Pointer - Area to be verified 1125 * Length - Size of area 1126 * 1127 * RETURN: TRUE if writable for entire length 1128 * 1129 * DESCRIPTION: Verify that a pointer is valid for writing 1130 * 1131 *****************************************************************************/ 1132 1133 BOOLEAN 1134 AcpiOsWritable ( 1135 void *Pointer, 1136 ACPI_SIZE Length) 1137 { 1138 1139 return (TRUE); 1140 } 1141 1142 1143 /****************************************************************************** 1144 * 1145 * FUNCTION: AcpiOsGetThreadId 1146 * 1147 * PARAMETERS: None 1148 * 1149 * RETURN: Id of the running thread 1150 * 1151 * DESCRIPTION: Get the ID of the current (running) thread 1152 * 1153 *****************************************************************************/ 1154 1155 ACPI_THREAD_ID 1156 AcpiOsGetThreadId ( 1157 void) 1158 { 1159 1160 return (ACPI_CAST_PTHREAD_T (pthread_self())); 1161 } 1162 1163 1164 /****************************************************************************** 1165 * 1166 * FUNCTION: AcpiOsSignal 1167 * 1168 * PARAMETERS: Function - ACPI CA signal function code 1169 * Info - Pointer to function-dependent structure 1170 * 1171 * RETURN: Status 1172 * 1173 * DESCRIPTION: Miscellaneous functions. Example implementation only. 1174 * 1175 *****************************************************************************/ 1176 1177 ACPI_STATUS 1178 AcpiOsSignal ( 1179 UINT32 Function, 1180 void *Info) 1181 { 1182 1183 switch (Function) 1184 { 1185 case ACPI_SIGNAL_FATAL: 1186 break; 1187 1188 case ACPI_SIGNAL_BREAKPOINT: 1189 break; 1190 1191 default: 1192 break; 1193 } 1194 1195 return (AE_OK); 1196 } 1197