1 /****************************************************************************** 2 * 3 * 1. Copyright Notice 4 * 5 * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. 6 * All rights reserved. 7 * 8 * 2. License 9 * 10 * 2.1. This is your license from Intel Corp. under its intellectual property 11 * rights. You may have additional license terms from the party that provided 12 * you this software, covering your right to use that party's intellectual 13 * property rights. 14 * 15 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 16 * copy of the source code appearing in this file ("Covered Code") an 17 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 18 * base code distributed originally by Intel ("Original Intel Code") to copy, 19 * make derivatives, distribute, use and display any portion of the Covered 20 * Code in any form, with the right to sublicense such rights; and 21 * 22 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 23 * license (with the right to sublicense), under only those claims of Intel 24 * patents that are infringed by the Original Intel Code, to make, use, sell, 25 * offer to sell, and import the Covered Code and derivative works thereof 26 * solely to the minimum extent necessary to exercise the above copyright 27 * license, and in no event shall the patent license extend to any additions 28 * to or modifications of the Original Intel Code. No other license or right 29 * is granted directly or by implication, estoppel or otherwise; 30 * 31 * The above copyright and patent license is granted only if the following 32 * conditions are met: 33 * 34 * 3. Conditions 35 * 36 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 37 * Redistribution of source code of any substantial portion of the Covered 38 * Code or modification with rights to further distribute source must include 39 * the above Copyright Notice, the above License, this list of Conditions, 40 * and the following Disclaimer and Export Compliance provision. In addition, 41 * Licensee must cause all Covered Code to which Licensee contributes to 42 * contain a file documenting the changes Licensee made to create that Covered 43 * Code and the date of any change. Licensee must include in that file the 44 * documentation of any changes made by any predecessor Licensee. Licensee 45 * must include a prominent statement that the modification is derived, 46 * directly or indirectly, from Original Intel Code. 47 * 48 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 49 * Redistribution of source code of any substantial portion of the Covered 50 * Code or modification without rights to further distribute source must 51 * include the following Disclaimer and Export Compliance provision in the 52 * documentation and/or other materials provided with distribution. In 53 * addition, Licensee may not authorize further sublicense of source of any 54 * portion of the Covered Code, and must include terms to the effect that the 55 * license from Licensee to its licensee is limited to the intellectual 56 * property embodied in the software Licensee provides to its licensee, and 57 * not to intellectual property embodied in modifications its licensee may 58 * make. 59 * 60 * 3.3. Redistribution of Executable. Redistribution in executable form of any 61 * substantial portion of the Covered Code or modification must reproduce the 62 * above Copyright Notice, and the following Disclaimer and Export Compliance 63 * provision in the documentation and/or other materials provided with the 64 * distribution. 65 * 66 * 3.4. Intel retains all right, title, and interest in and to the Original 67 * Intel Code. 68 * 69 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 70 * Intel shall be used in advertising or otherwise to promote the sale, use or 71 * other dealings in products derived from or relating to the Covered Code 72 * without prior written authorization from Intel. 73 * 74 * 4. Disclaimer and Export Compliance 75 * 76 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 77 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 78 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 79 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 80 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 81 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 82 * PARTICULAR PURPOSE. 83 * 84 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 85 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 86 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 87 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 88 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 89 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 90 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 91 * LIMITED REMEDY. 92 * 93 * 4.3. Licensee shall not export, either directly or indirectly, any of this 94 * software or system incorporating such software without first obtaining any 95 * required license or other approval from the U. S. Department of Commerce or 96 * any other agency or department of the United States Government. In the 97 * event Licensee exports any such software from the United States or 98 * re-exports any such software from a foreign destination, Licensee shall 99 * ensure that the distribution and export/re-export of the software is in 100 * compliance with all laws, regulations, orders, or other restrictions of the 101 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 102 * any of its subsidiaries will export/re-export any technical data, process, 103 * software, or service, directly or indirectly, to any country for which the 104 * United States government or any agency thereof requires an export license, 105 * other governmental approval, or letter of assurance, without first obtaining 106 * such license, approval or letter. 107 * 108 *****************************************************************************/ 109 110 #include <stdio.h> 111 #include <stdlib.h> 112 #include <unistd.h> 113 #include <sys/time.h> 114 115 #include "acpi.h" 116 #include "accommon.h" 117 #include "amlcode.h" 118 #include "acparser.h" 119 #include "acdebug.h" 120 121 #include <minix/driver.h> 122 #include <machine/pci_intel.h> 123 124 extern struct machine machine; 125 126 127 static u32_t pci_inb(u16_t port) { 128 u32_t value; 129 int s; 130 if ((s=sys_inb(port, &value)) !=OK) 131 printf("ACPI: warning, sys_inb failed: %d\n", s); 132 return value; 133 } 134 135 static u32_t pci_inw(u16_t port) { 136 u32_t value; 137 int s; 138 if ((s=sys_inw(port, &value)) !=OK) 139 printf("ACPI: warning, sys_inw failed: %d\n", s); 140 return value; 141 } 142 143 static u32_t pci_inl(u16_t port) { 144 u32_t value; 145 int s; 146 if ((s=sys_inl(port, &value)) !=OK) 147 printf("ACPI: warning, sys_inl failed: %d\n", s); 148 return value; 149 } 150 151 static void pci_outb(u16_t port, u8_t value) { 152 int s; 153 if ((s=sys_outb(port, value)) !=OK) 154 printf("ACPI: warning, sys_outb failed: %d\n", s); 155 } 156 157 static void pci_outw(u16_t port, u16_t value) { 158 int s; 159 if ((s=sys_outw(port, value)) !=OK) 160 printf("ACPI: warning, sys_outw failed: %d\n", s); 161 } 162 163 static void pci_outl(u16_t port, u32_t value) { 164 int s; 165 if ((s=sys_outl(port, value)) !=OK) 166 printf("ACPI: warning, sys_outl failed: %d\n", s); 167 } 168 169 /****************************************************************************** 170 * 171 * FUNCTION: AcpiOsInitialize, AcpiOsTerminate 172 * 173 * PARAMETERS: None 174 * 175 * RETURN: Status 176 * 177 * DESCRIPTION: Init and terminate. Nothing to do. 178 * 179 *****************************************************************************/ 180 181 ACPI_STATUS 182 AcpiOsInitialize (void) 183 { 184 return AE_OK; 185 } 186 187 188 ACPI_STATUS 189 AcpiOsTerminate (void) 190 { 191 return AE_OK; 192 } 193 194 195 /****************************************************************************** 196 * 197 * FUNCTION: AcpiOsPredefinedOverride 198 * 199 * PARAMETERS: InitVal - Initial value of the predefined object 200 * NewVal - The new value for the object 201 * 202 * RETURN: Status, pointer to value. Null pointer returned if not 203 * overriding. 204 * 205 * DESCRIPTION: Allow the OS to override predefined names 206 * 207 *****************************************************************************/ 208 209 ACPI_STATUS 210 AcpiOsPredefinedOverride ( 211 const ACPI_PREDEFINED_NAMES *InitVal, 212 ACPI_STRING *NewVal) 213 { 214 *NewVal = NULL; 215 return (AE_OK); 216 } 217 218 219 /****************************************************************************** 220 * 221 * FUNCTION: AcpiOsTableOverride 222 * 223 * PARAMETERS: ExistingTable - Header of current table (probably firmware) 224 * NewTable - Where an entire new table is returned. 225 * 226 * RETURN: Status, pointer to new table. Null pointer returned if no 227 * table is available to override 228 * 229 * DESCRIPTION: Return a different version of a table if one is available 230 * 231 *****************************************************************************/ 232 233 ACPI_STATUS 234 AcpiOsTableOverride ( 235 ACPI_TABLE_HEADER *ExistingTable, 236 ACPI_TABLE_HEADER **NewTable) 237 { 238 *NewTable = NULL; 239 return (AE_OK); 240 } 241 242 243 /****************************************************************************** 244 * 245 * FUNCTION: AcpiOsReadable 246 * 247 * PARAMETERS: Pointer - Area to be verified 248 * Length - Size of area 249 * 250 * RETURN: TRUE if readable for entire length 251 * 252 * DESCRIPTION: Verify that a pointer is valid for reading 253 * 254 *****************************************************************************/ 255 256 BOOLEAN 257 AcpiOsReadable ( 258 void *Pointer, 259 ACPI_SIZE Length) 260 { 261 panic("NOTIMPLEMENTED %s\n", __func__); 262 263 return (TRUE); 264 } 265 266 267 /****************************************************************************** 268 * 269 * FUNCTION: AcpiOsWritable 270 * 271 * PARAMETERS: Pointer - Area to be verified 272 * Length - Size of area 273 * 274 * RETURN: TRUE if writable for entire length 275 * 276 * DESCRIPTION: Verify that a pointer is valid for writing 277 * 278 *****************************************************************************/ 279 280 BOOLEAN 281 AcpiOsWritable ( 282 void *Pointer, 283 ACPI_SIZE Length) 284 { 285 panic("NOTIMPLEMENTED %s\n", __func__); 286 287 return (TRUE); 288 } 289 290 291 /****************************************************************************** 292 * 293 * FUNCTION: AcpiOsRedirectOutput 294 * 295 * PARAMETERS: Destination - An open file handle/pointer 296 * 297 * RETURN: None 298 * 299 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf 300 * 301 *****************************************************************************/ 302 303 void 304 AcpiOsRedirectOutput ( 305 void *Destination) 306 { 307 panic("NOTIMPLEMENTED %s\n", __func__); 308 } 309 310 311 /****************************************************************************** 312 * 313 * FUNCTION: AcpiOsPrintf 314 * 315 * PARAMETERS: fmt, ... Standard printf format 316 * 317 * RETURN: None 318 * 319 * DESCRIPTION: Formatted output 320 * 321 *****************************************************************************/ 322 323 void ACPI_INTERNAL_VAR_XFACE 324 AcpiOsPrintf ( 325 const char *Fmt, 326 ...) 327 { 328 va_list Args; 329 330 331 va_start (Args, Fmt); 332 333 #ifdef ACPI_BF_DEBUG 334 AcpiOsVprintf (Fmt, Args); 335 #endif 336 337 va_end (Args); 338 return; 339 } 340 341 342 /****************************************************************************** 343 * 344 * FUNCTION: AcpiOsVprintf 345 * 346 * PARAMETERS: fmt Standard printf format 347 * args Argument list 348 * 349 * RETURN: None 350 * 351 * DESCRIPTION: Formatted output with argument list pointer 352 * 353 *****************************************************************************/ 354 355 void 356 AcpiOsVprintf ( 357 const char *Fmt, 358 va_list Args) 359 { 360 361 vprintf (Fmt, Args); 362 printf("\n"); 363 } 364 365 366 /****************************************************************************** 367 * 368 * FUNCTION: AcpiOsGetLine 369 * 370 * PARAMETERS: fmt Standard printf format 371 * args Argument list 372 * 373 * RETURN: Actual bytes read 374 * 375 * DESCRIPTION: Formatted input with argument list pointer 376 * 377 *****************************************************************************/ 378 379 UINT32 380 AcpiOsGetLine ( 381 char *Buffer) 382 { 383 panic("NOTIMPLEMENTED %s\n", __func__); 384 return 0; 385 } 386 387 /****************************************************************************** 388 * 389 * FUNCTION: AcpiOsMapMemory 390 * 391 * PARAMETERS: where Physical address of memory to be mapped 392 * length How much memory to map 393 * 394 * RETURN: Pointer to mapped memory. Null on error. 395 * 396 * DESCRIPTION: Map physical memory into caller's address space 397 * 398 *****************************************************************************/ 399 400 void * 401 AcpiOsMapMemory ( 402 ACPI_PHYSICAL_ADDRESS where, /* not page aligned */ 403 ACPI_SIZE length) /* in bytes, not page-aligned */ 404 { 405 ACPI_PHYSICAL_ADDRESS addr; 406 void * vir; 407 unsigned sdiff; 408 409 addr = where & ~0xfff; /* align to 4k */ 410 sdiff = where - addr; 411 vir = vm_map_phys(SELF, (void *) addr, length + sdiff); 412 413 return (void *) ((char *)vir + sdiff); 414 } 415 416 417 /****************************************************************************** 418 * 419 * FUNCTION: AcpiOsUnmapMemory 420 * 421 * PARAMETERS: where Logical address of memory to be unmapped 422 * length How much memory to unmap 423 * 424 * RETURN: None. 425 * 426 * DESCRIPTION: Delete a previously created mapping. Where and Length must 427 * correspond to a previous mapping exactly. 428 * 429 *****************************************************************************/ 430 431 void 432 AcpiOsUnmapMemory ( 433 void *where, 434 ACPI_SIZE length) 435 { 436 } 437 438 439 /****************************************************************************** 440 * 441 * FUNCTION: AcpiOsAllocate 442 * 443 * PARAMETERS: Size Amount to allocate, in bytes 444 * 445 * RETURN: Pointer to the new allocation. Null on error. 446 * 447 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. 448 * 449 *****************************************************************************/ 450 451 void * 452 AcpiOsAllocate ( 453 ACPI_SIZE size) 454 { 455 void *Mem; 456 457 458 Mem = (void *) malloc ((size_t) size); 459 if (Mem == NULL) 460 printf("AcpiOsAllocate out of memory\n"); 461 462 return Mem; 463 } 464 465 466 /****************************************************************************** 467 * 468 * FUNCTION: AcpiOsFree 469 * 470 * PARAMETERS: mem Pointer to previously allocated memory 471 * 472 * RETURN: None. 473 * 474 * DESCRIPTION: Free memory allocated via AcpiOsAllocate 475 * 476 *****************************************************************************/ 477 478 void 479 AcpiOsFree ( 480 void *mem) 481 { 482 free(mem); 483 } 484 485 486 /****************************************************************************** 487 * 488 * FUNCTION: AcpiOsCreateSemaphore 489 * 490 * PARAMETERS: InitialUnits - Units to be assigned to the new semaphore 491 * OutHandle - Where a handle will be returned 492 * 493 * RETURN: Status 494 * 495 * DESCRIPTION: Create an OS semaphore 496 * 497 *****************************************************************************/ 498 499 ACPI_STATUS 500 AcpiOsCreateSemaphore ( 501 UINT32 MaxUnits, 502 UINT32 InitialUnits, 503 ACPI_HANDLE *OutHandle) 504 { 505 *OutHandle = NULL; 506 return AE_OK; 507 } 508 509 /****************************************************************************** 510 * 511 * FUNCTION: AcpiOsDeleteSemaphore 512 * 513 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 514 * 515 * RETURN: Status 516 * 517 * DESCRIPTION: Delete an OS semaphore 518 * 519 *****************************************************************************/ 520 521 ACPI_STATUS 522 AcpiOsDeleteSemaphore ( 523 ACPI_HANDLE Handle) 524 { 525 return AE_OK; 526 } 527 528 529 /****************************************************************************** 530 * 531 * FUNCTION: AcpiOsWaitSemaphore 532 * 533 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 534 * Units - How many units to wait for 535 * Timeout - How long to wait 536 * 537 * RETURN: Status 538 * 539 * DESCRIPTION: Wait for units 540 * 541 *****************************************************************************/ 542 543 ACPI_STATUS 544 AcpiOsWaitSemaphore ( 545 ACPI_HANDLE Handle, 546 UINT32 Units, 547 UINT16 Timeout) 548 { 549 return AE_OK; 550 } 551 552 553 /****************************************************************************** 554 * 555 * FUNCTION: AcpiOsSignalSemaphore 556 * 557 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore 558 * Units - Number of units to send 559 * 560 * RETURN: Status 561 * 562 * DESCRIPTION: Send units 563 * 564 *****************************************************************************/ 565 566 ACPI_STATUS 567 AcpiOsSignalSemaphore ( 568 ACPI_HANDLE Handle, 569 UINT32 Units) 570 { 571 return AE_OK; 572 } 573 574 575 ACPI_STATUS 576 AcpiOsCreateLock ( 577 ACPI_SPINLOCK *OutHandle) 578 { 579 *OutHandle = NULL; 580 return AE_OK; 581 } 582 583 void 584 AcpiOsDeleteLock ( 585 ACPI_SPINLOCK Handle) 586 { 587 } 588 589 590 ACPI_CPU_FLAGS 591 AcpiOsAcquireLock ( 592 ACPI_HANDLE Handle) 593 { 594 return (0); 595 } 596 597 598 void 599 AcpiOsReleaseLock ( 600 ACPI_SPINLOCK Handle, 601 ACPI_CPU_FLAGS Flags) 602 { 603 } 604 605 606 /****************************************************************************** 607 * 608 * FUNCTION: AcpiOsInstallInterruptHandler 609 * 610 * PARAMETERS: InterruptNumber Level handler should respond to. 611 * Isr Address of the ACPI interrupt handler 612 * ExceptPtr Where status is returned 613 * 614 * RETURN: Handle to the newly installed handler. 615 * 616 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI 617 * OS-independent handler. 618 * 619 *****************************************************************************/ 620 621 UINT32 622 AcpiOsInstallInterruptHandler ( 623 UINT32 InterruptNumber, 624 ACPI_OSD_HANDLER ServiceRoutine, 625 void *Context) 626 { 627 printf("AcpiOsInstallInterruptHandler NOT SUPPORTED\n"); 628 return AE_OK; 629 } 630 631 632 /****************************************************************************** 633 * 634 * FUNCTION: AcpiOsRemoveInterruptHandler 635 * 636 * PARAMETERS: Handle Returned when handler was installed 637 * 638 * RETURN: Status 639 * 640 * DESCRIPTION: Uninstalls an interrupt handler. 641 * 642 *****************************************************************************/ 643 644 ACPI_STATUS 645 AcpiOsRemoveInterruptHandler ( 646 UINT32 InterruptNumber, 647 ACPI_OSD_HANDLER ServiceRoutine) 648 { 649 printf("AcpiOsRemoveInterruptHandler NOT SUPPORTED\n"); 650 return AE_OK; 651 } 652 653 654 /****************************************************************************** 655 * 656 * FUNCTION: AcpiOsExecute 657 * 658 * PARAMETERS: Type - Type of execution 659 * Function - Address of the function to execute 660 * Context - Passed as a parameter to the function 661 * 662 * RETURN: Status. 663 * 664 * DESCRIPTION: Execute a new thread 665 * 666 *****************************************************************************/ 667 668 ACPI_STATUS 669 AcpiOsExecute ( 670 ACPI_EXECUTE_TYPE Type, 671 ACPI_OSD_EXEC_CALLBACK Function, 672 void *Context) 673 { 674 panic("NOTIMPLEMENTED %s\n", __func__); 675 return AE_OK; 676 } 677 678 679 /****************************************************************************** 680 * 681 * FUNCTION: AcpiOsBreakpoint 682 * 683 * PARAMETERS: Msg Message to print 684 * 685 * RETURN: Status 686 * 687 * DESCRIPTION: Print a message and break to the debugger. 688 * 689 *****************************************************************************/ 690 691 ACPI_STATUS 692 AcpiOsBreakpoint ( 693 char *Msg) 694 { 695 panic("NOTIMPLEMENTED %s\n", __func__); 696 return AE_OK; 697 } 698 699 700 /****************************************************************************** 701 * 702 * FUNCTION: AcpiOsStall 703 * 704 * PARAMETERS: microseconds To sleep 705 * 706 * RETURN: Blocks until sleep is completed. 707 * 708 * DESCRIPTION: Sleep at microsecond granularity 709 * 710 *****************************************************************************/ 711 712 void 713 AcpiOsStall ( 714 UINT32 microseconds) 715 { 716 if (microseconds > 0) 717 usleep (microseconds); 718 719 return; 720 } 721 722 723 /****************************************************************************** 724 * 725 * FUNCTION: AcpiOsSleep 726 * 727 * PARAMETERS: milliseconds To sleep 728 * 729 * RETURN: Blocks until sleep is completed. 730 * 731 * DESCRIPTION: Sleep at millisecond granularity 732 * 733 *****************************************************************************/ 734 735 void 736 AcpiOsSleep ( 737 ACPI_INTEGER milliseconds) 738 { 739 if ((milliseconds / 1000) > 0) 740 sleep (milliseconds / 1000); 741 742 if ((milliseconds % 1000) > 0) 743 usleep ((milliseconds % 1000) * 1000); 744 745 return; 746 } 747 748 /****************************************************************************** 749 * 750 * FUNCTION: AcpiOsGetTimer 751 * 752 * PARAMETERS: None 753 * 754 * RETURN: Current time in 100 nanosecond units 755 * 756 * DESCRIPTION: Get the current system time 757 * 758 *****************************************************************************/ 759 760 UINT64 761 AcpiOsGetTimer (void) 762 { 763 struct timeval time; 764 765 gettimeofday (&time, NULL); 766 return (((UINT64) time.tv_sec * 10000000) + 767 ((UINT64) time.tv_usec * 10)); 768 } 769 770 771 /****************************************************************************** 772 * 773 * FUNCTION: AcpiOsValidateInterface 774 * 775 * PARAMETERS: Interface - Requested interface to be validated 776 * 777 * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise 778 * 779 * DESCRIPTION: Match an interface string to the interfaces supported by the 780 * host. Strings originate from an AML call to the _OSI method. 781 * 782 *****************************************************************************/ 783 784 ACPI_STATUS 785 AcpiOsValidateInterface ( 786 char *Interface) 787 { 788 return (AE_SUPPORT); 789 } 790 791 792 /* TEMPORARY STUB FUNCTION */ 793 void 794 AcpiOsDerivePciId( 795 ACPI_HANDLE rhandle, 796 ACPI_HANDLE chandle, 797 ACPI_PCI_ID **PciId) 798 { 799 /* we do nothing here, we keep the PciId unchanged */ 800 } 801 802 803 /****************************************************************************** 804 * 805 * FUNCTION: AcpiOsReadPort 806 * 807 * PARAMETERS: Address Address of I/O port/register to read 808 * Value Where value is placed 809 * Width Number of bits 810 * 811 * RETURN: Value read from port 812 * 813 * DESCRIPTION: Read data from an I/O port or register 814 * 815 *****************************************************************************/ 816 817 ACPI_STATUS 818 AcpiOsReadPort ( 819 ACPI_IO_ADDRESS Address, 820 UINT32 *Value, 821 UINT32 Width) 822 { 823 *Value = 0; 824 switch (Width) { 825 case 8: 826 sys_inb(Address, Value); 827 break; 828 case 16: 829 sys_inw(Address, Value); 830 break; 831 case 32: 832 sys_inl(Address, Value); 833 break; 834 } 835 return AE_OK; 836 } 837 838 839 /****************************************************************************** 840 * 841 * FUNCTION: AcpiOsWritePort 842 * 843 * PARAMETERS: Address Address of I/O port/register to write 844 * Value Value to write 845 * Width Number of bits 846 * 847 * RETURN: None 848 * 849 * DESCRIPTION: Write data to an I/O port or register 850 * 851 *****************************************************************************/ 852 853 ACPI_STATUS 854 AcpiOsWritePort ( 855 ACPI_IO_ADDRESS Address, 856 UINT32 Value, 857 UINT32 Width) 858 { 859 switch (Width) { 860 case 8: 861 sys_outb(Address, Value); 862 break; 863 case 16: 864 sys_outw(Address, Value); 865 break; 866 case 32: 867 sys_outl(Address, Value); 868 break; 869 } 870 return AE_OK; 871 return AE_OK; 872 } 873 874 875 /****************************************************************************** 876 * 877 * FUNCTION: AcpiOsReadMemory 878 * 879 * PARAMETERS: Address Physical Memory Address to read 880 * Value Where value is placed 881 * Width Number of bits 882 * 883 * RETURN: Value read from physical memory address 884 * 885 * DESCRIPTION: Read data from a physical memory address 886 * 887 *****************************************************************************/ 888 889 ACPI_STATUS 890 AcpiOsReadMemory ( 891 ACPI_PHYSICAL_ADDRESS Address, 892 UINT32 *Value, 893 UINT32 Width) 894 { 895 /* FIXME this operation is ignored */ 896 *Value = 0; 897 898 return (AE_OK); 899 } 900 901 902 /****************************************************************************** 903 * 904 * FUNCTION: AcpiOsWriteMemory 905 * 906 * PARAMETERS: Address Physical Memory Address to write 907 * Value Value to write 908 * Width Number of bits 909 * 910 * RETURN: None 911 * 912 * DESCRIPTION: Write data to a physical memory address 913 * 914 *****************************************************************************/ 915 916 ACPI_STATUS 917 AcpiOsWriteMemory ( 918 ACPI_PHYSICAL_ADDRESS Address, 919 UINT32 Value, 920 UINT32 Width) 921 { 922 /* FIXME this operation is ignored */ 923 return (AE_OK); 924 } 925 926 927 ACPI_THREAD_ID 928 AcpiOsGetThreadId(void) 929 { 930 return (ACPI_THREAD_ID) 1; 931 } 932 933 934 /****************************************************************************** 935 * 936 * FUNCTION: AcpiOsSignal 937 * 938 * PARAMETERS: Function ACPI CA signal function code 939 * Info Pointer to function-dependent structure 940 * 941 * RETURN: Status 942 * 943 * DESCRIPTION: Miscellaneous functions 944 * 945 *****************************************************************************/ 946 947 ACPI_STATUS 948 AcpiOsSignal ( 949 UINT32 Function, 950 void *Info) 951 { 952 panic("NOTIMPLEMENTED %s\n", __func__); 953 return (AE_OK); 954 } 955 956 /****************************************************************************** 957 * 958 * FUNCTION: AcpiOsGetRootPointer 959 * 960 * PARAMETERS: None 961 * 962 * RETURN: RSDP physical address 963 * 964 * DESCRIPTION: Gets the root pointer (RSDP) 965 * 966 *****************************************************************************/ 967 968 ACPI_PHYSICAL_ADDRESS AcpiOsGetRootPointer ( 969 void) 970 { 971 return machine.acpi_rsdp; 972 } 973 974 /****************************************************************************** 975 * 976 * FUNCTION: AcpiOsReadPciConfiguration 977 * 978 * PARAMETERS: PciId Seg/Bus/Dev 979 * Register Device Register 980 * Value Buffer where value is placed 981 * Width Number of bits 982 * 983 * RETURN: Status 984 * 985 * DESCRIPTION: Read data from PCI configuration space 986 * 987 *****************************************************************************/ 988 989 ACPI_STATUS 990 AcpiOsReadPciConfiguration ( 991 ACPI_PCI_ID *PciId, 992 UINT32 Register, 993 void *Value, 994 UINT32 Width) 995 { 996 int err; 997 998 switch (Width) { 999 case 8: 1000 *(u8_t *)Value = PCII_RREG8_(PciId->Bus, PciId->Device, 1001 PciId->Function, Register); 1002 break; 1003 case 16: 1004 *(u16_t *)Value = PCII_RREG16_(PciId->Bus, PciId->Device, 1005 PciId->Function, Register); 1006 break; 1007 case 32: 1008 *(u32_t *)Value = PCII_RREG32_(PciId->Bus, PciId->Device, 1009 PciId->Function, Register); 1010 break; 1011 default: 1012 panic("NOT IMPLEMENTED\n"); 1013 } 1014 1015 if (OK != (err = sys_outl(PCII_CONFADD, PCII_UNSEL))) 1016 printf("ACPI: warning, sys_outl failed: %d\n", err); 1017 1018 return AE_OK; 1019 } 1020 1021 1022 /****************************************************************************** 1023 * 1024 * FUNCTION: AcpiOsWritePciConfiguration 1025 * 1026 * PARAMETERS: PciId Seg/Bus/Dev 1027 * Register Device Register 1028 * Value Value to be written 1029 * Width Number of bits 1030 * 1031 * RETURN: Status. 1032 * 1033 * DESCRIPTION: Write data to PCI configuration space 1034 * 1035 *****************************************************************************/ 1036 1037 ACPI_STATUS 1038 AcpiOsWritePciConfiguration ( 1039 ACPI_PCI_ID *PciId, 1040 UINT32 Register, 1041 ACPI_INTEGER Value, 1042 UINT32 Width) 1043 { 1044 int err; 1045 1046 switch (Width) { 1047 case 8: 1048 PCII_WREG8_(PciId->Bus, PciId->Device, 1049 PciId->Function, Register, Value); 1050 break; 1051 case 16: 1052 PCII_WREG16_(PciId->Bus, PciId->Device, 1053 PciId->Function, Register, Value); 1054 break; 1055 case 32: 1056 PCII_WREG32_(PciId->Bus, PciId->Device, 1057 PciId->Function, Register, Value); 1058 break; 1059 default: 1060 panic("NOT IMPLEMENTED\n"); 1061 } 1062 1063 if (OK != (err = sys_outl(PCII_CONFADD, PCII_UNSEL))) 1064 printf("ACPI: warning, sys_outl failed: %d\n", err); 1065 1066 return AE_OK; 1067 } 1068