Home | History | Annotate | Line # | Download | only in service_layers
      1 /******************************************************************************
      2  *
      3  * Module Name: oszephyr - Zephyr OSL
      4  *
      5  *****************************************************************************/
      6 
      7 /*
      8  * Copyright (C) 2000 - 2026, 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 MERCHANTABILITY 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 #include "acpi.h"
     45 #include "accommon.h"
     46 #include "acapps.h"
     47 #include "aslcompiler.h"
     48 #include <zephyr/arch/x86/x86_acpi_osal.h>
     49 #include <zephyr/drivers/pcie/pcie.h>
     50 #include <zephyr/dt-bindings/interrupt-controller/intel-ioapic.h>
     51 #include <zephyr/sys/__assert.h>
     52 
     53 #include <zephyr/logging/log.h>
     54 LOG_MODULE_DECLARE(acpica, LOG_LEVEL_ERR);
     55 
     56 typedef void (*zephyr_irq_t)(const void *);
     57 
     58 /* Global variables use from acpica lib. */
     59 BOOLEAN                     AslGbl_DoTemplates = FALSE;
     60 BOOLEAN                     AslGbl_VerboseTemplates = FALSE;
     61 
     62 char                        AslGbl_MsgBuffer[ASL_MSG_BUFFER_SIZE];
     63 static BOOLEAN              EnDbgPrint;
     64 static ACPI_PHYSICAL_ADDRESS RsdpPhyAdd;
     65 
     66 /******************************************************************************
     67  *
     68  * FUNCTION:    AcpiOsReadable
     69  *
     70  * PARAMETERS:  Pointer             - Area to be verified
     71  *              Length              - Size of area
     72  *
     73  * RETURN:      TRUE if readable for entire Length
     74  *
     75  * DESCRIPTION: Verify that a pointer is valid for reading
     76  *
     77  *****************************************************************************/
     78 
     79 BOOLEAN
     80 AcpiOsReadable (
     81     void                    *Pointer,
     82     ACPI_SIZE               Length)
     83 {
     84     return (TRUE);
     85 }
     86 
     87 
     88 /******************************************************************************
     89  *
     90  * FUNCTION:    AcpiEnableDbgPrint
     91  *
     92  * PARAMETERS:  en, 	            - Enable/Disable debug print
     93  *
     94  * RETURN:      None
     95  *
     96  * DESCRIPTION: Formatted output
     97  *
     98  *****************************************************************************/
     99 
    100 void
    101 AcpiEnableDbgPrint (
    102     bool                    Enable)
    103 {
    104     if (Enable)
    105     {
    106         EnDbgPrint = TRUE;
    107     }
    108     else
    109     {
    110         EnDbgPrint = FALSE;
    111     }
    112 }
    113 
    114 
    115 /******************************************************************************
    116  *
    117  * FUNCTION:    AcpiOsPrintf
    118  *
    119  * PARAMETERS:  Fmt, ...            - Standard printf format
    120  *
    121  * RETURN:      None
    122  *
    123  * DESCRIPTION: Formatted output
    124  *
    125  *****************************************************************************/
    126 
    127 void ACPI_INTERNAL_VAR_XFACE
    128 AcpiOsPrintf (
    129     const char              *Fmt,
    130     ...)
    131 {
    132     va_list                 args;
    133 
    134     va_start (args, Fmt);
    135 
    136     if (EnDbgPrint)
    137     {
    138         vprintk (Fmt, args);
    139     }
    140 
    141     va_end (args);
    142 }
    143 
    144 
    145 /******************************************************************************
    146  *
    147  * FUNCTION:    AcpiOsGetLine
    148  *
    149  * PARAMETERS:  Buffer              - Where to return the command line
    150  *              BufferLength        - Maximum Length of Buffer
    151  *              BytesRead           - Where the actual byte count is returned
    152  *
    153  * RETURN:      Status and actual bytes read
    154  *
    155  * DESCRIPTION: Formatted input with argument list pointer
    156  *
    157  *****************************************************************************/
    158 
    159 ACPI_STATUS
    160 AcpiOsGetLine (
    161     char                    *Buffer,
    162     UINT32                  BufferLength,
    163     UINT32                  *BytesRead)
    164 {
    165     return (-1);
    166 }
    167 
    168 
    169 /******************************************************************************
    170  *
    171  * FUNCTION:    AcpiOsAllocate
    172  *
    173  * PARAMETERS:  Size                - Amount to allocate, in bytes
    174  *
    175  * RETURN:      Pointer to the new allocation. Null on error.
    176  *
    177  * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
    178  *
    179  *****************************************************************************/
    180 
    181 void *
    182 AcpiOsAllocate (
    183     ACPI_SIZE               Size)
    184 {
    185     return (k_malloc (Size));
    186 }
    187 
    188 
    189 #ifdef USE_NATIVE_ALLOCATE_ZEROED
    190 /******************************************************************************
    191  *
    192  * FUNCTION:    AcpiOsAllocateZeroed
    193  *
    194  * PARAMETERS:  Size                - Amount to allocate, in bytes
    195  *
    196  * RETURN:      Pointer to the new allocation. Null on error.
    197  *
    198  * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS.
    199  *
    200  *****************************************************************************/
    201 
    202 void *
    203 AcpiOsAllocateZeroed (
    204     ACPI_SIZE               Size)
    205 {
    206     void *mem;
    207 
    208     mem = AcpiOsAllocate (Size);
    209 
    210     if (mem)
    211     {
    212         memset (mem, 0, Size);
    213     }
    214 
    215     return (mem);
    216 }
    217 #endif
    218 
    219 
    220 /******************************************************************************
    221  *
    222  * FUNCTION:    AcpiOsFree
    223  *
    224  * PARAMETERS:  Mem                 - Pointer to previously allocated memory
    225  *
    226  * RETURN:      None.
    227  *
    228  * DESCRIPTION: Free memory allocated via AcpiOsAllocate
    229  *
    230  *****************************************************************************/
    231 
    232 void
    233 AcpiOsFree (
    234     void                    *Mem)
    235 {
    236     k_free (Mem);
    237 }
    238 
    239 
    240 /******************************************************************************
    241  *
    242  * FUNCTION:    AcpiOsReadMemory
    243  *
    244  * PARAMETERS:  Address             - Physical Memory Address to read
    245  *              Value               - Where Value is placed
    246  *              Width               - Number of bits (8,16,32, or 64)
    247  *
    248  * RETURN:      Value read from physical memory Address. Always returned
    249  *              as a 64-bit integer, regardless of the read Width.
    250  *
    251  * DESCRIPTION: Read data from a physical memory Address
    252  *
    253  *****************************************************************************/
    254 
    255 ACPI_STATUS
    256 AcpiOsReadMemory (
    257     ACPI_PHYSICAL_ADDRESS   Address,
    258     UINT64                  *Value,
    259     UINT32                  Width)
    260 {
    261     switch (Width)
    262     {
    263     case 8:
    264 
    265         *((UINT8 *) Value) = sys_read8 (Address);
    266         break;
    267 
    268     case 16:
    269 
    270         *((UINT16 *) Value) = sys_read16 (Address);
    271         break;
    272 
    273     case 32:
    274 
    275         *((UINT32 *) Value) = sys_read32 (Address);
    276         break;
    277 #if defined(__x86_64__)
    278     case 64:
    279 
    280         *((UINT64 *) Value) = sys_read64 (Address);
    281         break;
    282 #endif
    283     default:
    284 
    285         return (AE_BAD_PARAMETER);
    286     }
    287 
    288     return (AE_OK);
    289 }
    290 
    291 
    292 /******************************************************************************
    293  *
    294  * FUNCTION:    AcpiOsWriteMemory
    295  *
    296  * PARAMETERS:  Address             - Physical Memory Address to write
    297  *              Value               - Value to write
    298  *              Width               - Number of bits (8,16,32, or 64)
    299  *
    300  * RETURN:      None
    301  *
    302  * DESCRIPTION: Write data to a physical memory Address
    303  *
    304  *****************************************************************************/
    305 
    306 ACPI_STATUS
    307 AcpiOsWriteMemory (
    308     ACPI_PHYSICAL_ADDRESS   Address,
    309     UINT64                  Value,
    310     UINT32                  Width)
    311 {
    312     switch (Width)
    313     {
    314     case 8:
    315 
    316         sys_write8 ((UINT8) Value, Address);
    317         break;
    318 
    319     case 16:
    320 
    321         sys_write16 ((UINT16) Value, Address);
    322         break;
    323 
    324     case 32:
    325 
    326         sys_write32 ((UINT32) Value, Address);
    327         break;
    328 #if defined(__x86_64__)
    329     case 64:
    330 
    331         sys_write64 ((UINT64) Value, Address);
    332         break;
    333 #endif
    334     default:
    335 
    336         return (AE_BAD_PARAMETER);
    337     }
    338 
    339     return (AE_OK);
    340 }
    341 
    342 
    343 /******************************************************************************
    344  *
    345  * FUNCTION:    AcpiOsReadPort
    346  *
    347  * PARAMETERS:  Address             - Address of I/O port/register to read
    348  *              Value               - Where Value is placed
    349  *              Width               - Number of bits
    350  *
    351  * RETURN:      Value read from port
    352  *
    353  * DESCRIPTION: Read data from an I/O port or register
    354  *
    355  *****************************************************************************/
    356 
    357 ACPI_STATUS
    358 AcpiOsReadPort (
    359     ACPI_IO_ADDRESS         Address,
    360     UINT32                  *Value,
    361     UINT32                  Width)
    362 {
    363 
    364     switch (Width)
    365     {
    366     case 8:
    367 
    368         *((UINT8 *) Value) = sys_in8 (Address);
    369         break;
    370 
    371     case 16:
    372 
    373         *((UINT16 *) Value) = sys_in16 (Address);
    374         break;
    375 
    376     case 32:
    377 
    378         *((UINT32 *) Value) = sys_in32 (Address);
    379         break;
    380 
    381     case 64:
    382 
    383         *((UINT32 *) Value) = sys_in32 (Address);
    384         *((UINT32 *) Value + 4) = sys_in32 (Address + 4);
    385         break;
    386 
    387     default:
    388 
    389         return (AE_BAD_PARAMETER);
    390     }
    391 
    392     return (AE_OK);
    393 }
    394 
    395 
    396 /******************************************************************************
    397  *
    398  * FUNCTION:    AcpiOsWritePort
    399  *
    400  * PARAMETERS:  Address             - Address of I/O port/register to write
    401  *              Value               - Value to write
    402  *              Width               - Number of bits
    403  *
    404  * RETURN:      None
    405  *
    406  * DESCRIPTION: Write data to an I/O port or register
    407  *
    408  *****************************************************************************/
    409 
    410 ACPI_STATUS
    411 AcpiOsWritePort (
    412     ACPI_IO_ADDRESS         Address,
    413     UINT32                  Value,
    414     UINT32                  Width)
    415 {
    416 
    417     switch (Width)
    418     {
    419     case 8:
    420 
    421         sys_out8 ((UINT8) Value, Address);
    422         break;
    423 
    424     case 16:
    425 
    426         sys_out16 ((UINT16) Value, Address);
    427         break;
    428 
    429     case 32:
    430 
    431         sys_out32 ((UINT32) Value, Address);
    432         break;
    433 
    434     case 64:
    435 
    436         sys_out32 ((UINT32) Value, Address);
    437         sys_out32 ((UINT32) (Value + 4), (Address + 4));
    438         break;
    439 
    440     default:
    441 
    442         return (AE_BAD_PARAMETER);
    443     }
    444 
    445     return (AE_OK);
    446 }
    447 
    448 
    449 /******************************************************************************
    450  *
    451  * FUNCTION:    AcpiOsWritePciConfiguration
    452  *
    453  * PARAMETERS:  PciId               - Seg/Bus/Dev
    454  *              Register            - Device Register
    455  *              Value               - Value to be written
    456  *              Width               - Number of bits
    457  *
    458  * RETURN:      Status
    459  *
    460  * DESCRIPTION: Write data to PCI configuration space
    461  *
    462  *****************************************************************************/
    463 
    464 ACPI_STATUS
    465 AcpiOsWritePciConfiguration (
    466     ACPI_PCI_ID             *PciId,
    467     UINT32                  Register,
    468     UINT64                  Value,
    469     UINT32                  Width)
    470 {
    471     UINT32                  value32;
    472     pcie_bdf_t              bdf = PCIE_BDF (PciId->Bus, PciId->Device, PciId->Function);
    473 
    474 
    475     switch (Width)
    476     {
    477     case 8:
    478 
    479         value32 = pcie_conf_read (bdf, Register);
    480         value32 = (value32 & 0xffffff00) | (UINT8) Value;
    481         pcie_conf_write (bdf, Register, value32);
    482         break;
    483 
    484     case 16:
    485 
    486         value32 = pcie_conf_read (bdf, Register);
    487         value32 = (value32 & 0xffff0000) | (UINT16) Value;
    488         pcie_conf_write (bdf, Register, value32);
    489         break;
    490 
    491     case 32:
    492 
    493         pcie_conf_write (bdf, Register, (UINT32) Value);
    494         break;
    495 
    496     case 64:
    497 
    498         pcie_conf_write (bdf, Register, (UINT32) Value);
    499         pcie_conf_write (bdf, (Register + 4), (UINT32) (Value >> 32));
    500         break;
    501 
    502     default:
    503 
    504         return (AE_BAD_PARAMETER);
    505     }
    506 
    507     return (AE_OK);
    508 }
    509 
    510 
    511 /******************************************************************************
    512  *
    513  * FUNCTION:    AcpiOsReadPciConfiguration
    514  *
    515  * PARAMETERS:  PciId               - Seg/Bus/Dev
    516  *              Register            - Device Register
    517  *              Value               - Buffer Where Value is placed
    518  *              Width               - Number of bits
    519  *
    520  * RETURN:      Status
    521  *
    522  * DESCRIPTION: Read data from PCI configuration space
    523  *
    524  *****************************************************************************/
    525 
    526 ACPI_STATUS
    527 AcpiOsReadPciConfiguration (
    528     ACPI_PCI_ID             *PciId,
    529     UINT32                  Register,
    530     UINT64                  *Value,
    531     UINT32                  Width)
    532 {
    533 
    534     pcie_bdf_t bdf = PCIE_BDF (PciId->Bus, PciId->Device, PciId->Function);
    535 
    536     switch (Width)
    537     {
    538     case 8:
    539 
    540         *((UINT8 *) Value) = (UINT8) pcie_conf_read (bdf, Register);
    541         break;
    542 
    543     case 16:
    544 
    545         *((UINT16 *) Value) = (UINT16) pcie_conf_read (bdf, Register);
    546         break;
    547 
    548     case 32:
    549 
    550         *((UINT32 *) Value) = (UINT32) pcie_conf_read (bdf, Register);
    551         break;
    552 
    553     case 64:
    554 
    555         *((UINT32 *) Value) = (UINT32) pcie_conf_read (bdf, Register);
    556         *((UINT32 *) Value + 1) = (UINT32) pcie_conf_read (bdf, (Register + 4));
    557         break;
    558 
    559     default:
    560 
    561         return (AE_BAD_PARAMETER);
    562     }
    563 
    564     return (AE_OK);
    565 }
    566 
    567 
    568 /******************************************************************************
    569  *
    570  * FUNCTION:    AcpiOsRedirectOutput
    571  *
    572  * PARAMETERS:  Destination         - An open file handle/pointer
    573  *
    574  * RETURN:      None
    575  *
    576  * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
    577  *
    578  *****************************************************************************/
    579 
    580 void
    581 AcpiOsRedirectOutput (
    582     void                    *Destination)
    583 {
    584 
    585 }
    586 
    587 
    588 /******************************************************************************
    589  *
    590  * FUNCTION:    AcpiOsPredefinedOverride
    591  *
    592  * PARAMETERS:  InitVal             - Initial Value of the predefined object
    593  *              NewVal              - The new Value for the object
    594  *
    595  * RETURN:      Status, pointer to Value. Null pointer returned if not
    596  *              overriding.
    597  *
    598  * DESCRIPTION: Allow the OS to override predefined names
    599  *
    600  *****************************************************************************/
    601 
    602 ACPI_STATUS
    603 AcpiOsPredefinedOverride (
    604     const ACPI_PREDEFINED_NAMES *InitVal,
    605     ACPI_STRING                 *NewVal)
    606 {
    607 
    608     if (!InitVal || !NewVal)
    609     {
    610         return (AE_BAD_PARAMETER);
    611     }
    612 
    613     *NewVal = NULL;
    614 
    615     return (AE_OK);
    616 }
    617 
    618 
    619 /******************************************************************************
    620  *
    621  * FUNCTION:    AcpiOsTableOverride
    622  *
    623  * PARAMETERS:  ExistingTable       - Header of current table (probably firmware)
    624  *              NewTable            - Where an entire new table is returned.
    625  *
    626  * RETURN:      Status, pointer to new table. Null pointer returned if no
    627  *              table is available to override
    628  *
    629  * DESCRIPTION: Return a different version of a table if one is available
    630  *
    631  *****************************************************************************/
    632 
    633 ACPI_STATUS
    634 AcpiOsTableOverride (
    635     ACPI_TABLE_HEADER       *ExistingTable,
    636     ACPI_TABLE_HEADER       **NewTable)
    637 {
    638 
    639     if (!ExistingTable || !NewTable)
    640     {
    641         return (AE_BAD_PARAMETER);
    642     }
    643 
    644     *NewTable = NULL;
    645 
    646     return (AE_NO_ACPI_TABLES);
    647 }
    648 
    649 
    650 /******************************************************************************
    651  *
    652  * FUNCTION:    AcpiOsGetRootPointer
    653  *
    654  * PARAMETERS:  None
    655  *
    656  * RETURN:      RSDP physical Address
    657  *
    658  * DESCRIPTION: Gets the root pointer (RSDP)
    659  *
    660  *****************************************************************************/
    661 
    662 ACPI_PHYSICAL_ADDRESS
    663 AcpiOsGetRootPointer (
    664     void)
    665 {
    666 	 LOG_DBG ("");
    667 
    668 	if(RsdpPhyAdd)
    669 	{
    670 		return RsdpPhyAdd;
    671 	}
    672 
    673 	RsdpPhyAdd = (ACPI_PHYSICAL_ADDRESS)acpi_rsdp_get();
    674 
    675 	return RsdpPhyAdd;
    676 }
    677 
    678 #ifndef ACPI_USE_NATIVE_MEMORY_MAPPING
    679 /******************************************************************************
    680  *
    681  * FUNCTION:    AcpiOsMapMemory
    682  *
    683  * PARAMETERS:  Where               - Physical Address of memory to be mapped
    684  *              Length              - How much memory to map
    685  *
    686  * RETURN:      Pointer to mapped memory. Null on error.
    687  *
    688  * DESCRIPTION: Map physical memory into caller's Address space
    689  *
    690  *****************************************************************************/
    691 
    692 void *
    693 AcpiOsMapMemory (
    694     ACPI_PHYSICAL_ADDRESS   Where,
    695     ACPI_SIZE               Length)
    696 {
    697     uint8_t                 *VirtlAdd;
    698 
    699     LOG_DBG ("");
    700     z_phys_map (&VirtlAdd, Where, Length, K_MEM_PERM_RW);
    701     return ((void *) VirtlAdd);
    702 }
    703 #endif
    704 
    705 
    706 /******************************************************************************
    707  *
    708  * FUNCTION:    AcpiOsUnmapMemory
    709  *
    710  * PARAMETERS:  Where               - Logical Address of memory to be unmapped
    711  *              Length              - How much memory to unmap
    712  *
    713  * RETURN:      None.
    714  *
    715  * DESCRIPTION: Delete a previously created mapping. Where and Length must
    716  *              correspond to a previous mapping exactly.
    717  *
    718  *****************************************************************************/
    719 
    720 void
    721 AcpiOsUnmapMemory (
    722     void                    *Where,
    723     ACPI_SIZE               Length)
    724 {
    725     LOG_DBG ("");
    726     z_phys_unmap (Where, Length);
    727 }
    728 
    729 
    730 /******************************************************************************
    731  *
    732  * FUNCTION:    AcpiOsPhysicalTableOverride
    733  *
    734  * PARAMETERS:  ExistingTable       - Header of current table (probably firmware)
    735  *              NewAddress          - Where new table Address is returned
    736  *                                    (Physical Address)
    737  *              NewTableLength      - Where new table Length is returned
    738  *
    739  * RETURN:      Status, Address/Length of new table. Null pointer returned
    740  *              if no table is available to override.
    741  *
    742  * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
    743  *
    744  *****************************************************************************/
    745 
    746 ACPI_STATUS
    747 AcpiOsPhysicalTableOverride (
    748     ACPI_TABLE_HEADER       *ExistingTable,
    749     ACPI_PHYSICAL_ADDRESS   *NewAddress,
    750     UINT32                  *NewTableLength)
    751 {
    752 
    753     LOG_DBG ("");
    754     return (AE_SUPPORT);
    755 }
    756 
    757 
    758 /******************************************************************************
    759  *
    760  * FUNCTION:    AcpiOsInitialize
    761  *
    762  * PARAMETERS:  None
    763  *
    764  * RETURN:      Status
    765  *
    766  * DESCRIPTION: Init this OSL
    767  *
    768  *****************************************************************************/
    769 
    770 ACPI_STATUS
    771 AcpiOsInitialize (
    772     void)
    773 {
    774     LOG_DBG ("");
    775     return (AE_OK);
    776 }
    777 
    778 
    779 /******************************************************************************
    780  *
    781  * FUNCTION:    AcpiOsStall
    782  *
    783  * PARAMETERS:  Microseconds        - Time to stall
    784  *
    785  * RETURN:      None. Blocks until stall is completed.
    786  *
    787  * DESCRIPTION: Sleep at microsecond granularity
    788  *
    789  *****************************************************************************/
    790 
    791 void
    792 AcpiOsStall (
    793     UINT32                  Microseconds)
    794 {
    795     k_busy_wait (Microseconds);
    796 }
    797 
    798 
    799 /******************************************************************************
    800  *
    801  * FUNCTION:    AcpiOsSleep
    802  *
    803  * PARAMETERS:  Milliseconds        - Time to sleep
    804  *
    805  * RETURN:      None. Blocks until sleep is completed.
    806  *
    807  * DESCRIPTION: Sleep at millisecond granularity
    808  *
    809  *****************************************************************************/
    810 
    811 void
    812 AcpiOsSleep (
    813     UINT64                  Milliseconds)
    814 {
    815     k_msleep ((UINT32) Milliseconds);
    816 }
    817 
    818 
    819 /******************************************************************************
    820  *
    821  * FUNCTION:    AcpiOsEnterSleep
    822  *
    823  * PARAMETERS:  SleepState          - Which sleep state to enter
    824  *              RegaValue           - Register A Value
    825  *              RegbValue           - Register B Value
    826  *
    827  * RETURN:      Status
    828  *
    829  * DESCRIPTION: A hook before writing sleep registers to enter the sleep
    830  *              state. Return AE_CTRL_SKIP to skip further sleep register
    831  *              writes.
    832  *
    833  *****************************************************************************/
    834 
    835 ACPI_STATUS
    836 AcpiOsEnterSleep (
    837     UINT8                   SleepState,
    838     UINT32                  RegaValue,
    839     UINT32                  RegbValue)
    840 {
    841     __ASSERT (FALSE, "function Not implemented");
    842     return (AE_OK);
    843 }
    844 
    845 
    846 /******************************************************************************
    847  *
    848  * FUNCTION:    AcpiOsGetTimer
    849  *
    850  * PARAMETERS:  None
    851  *
    852  * RETURN:      Current ticks in 100-nanosecond units
    853  *
    854  * DESCRIPTION: Get the Value of a system timer
    855  *
    856  ******************************************************************************/
    857 
    858 UINT64
    859 AcpiOsGetTimer (
    860     void)
    861 {
    862     return acpi_timer_get();
    863 }
    864 
    865 /******************************************************************************
    866  *
    867  * FUNCTION:    AcpiOsInstallInterruptHandler
    868  *
    869  * PARAMETERS:  InterruptNumber     - Level handler should respond to.
    870  *              ServiceRoutine      - Address of the ACPI interrupt handler
    871  *              Context             - User context
    872  *
    873  * RETURN:      Handle to the newly installed handler.
    874  *
    875  * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
    876  *              OS-independent handler.
    877  *
    878  *****************************************************************************/
    879 
    880 UINT32
    881 AcpiOsInstallInterruptHandler (
    882     UINT32                  InterruptNumber,
    883     ACPI_OSD_HANDLER        ServiceRoutine,
    884     void                    *Context)
    885 {
    886     LOG_DBG ("");
    887     irq_connect_dynamic (InterruptNumber, 3, (zephyr_irq_t) ServiceRoutine, Context,
    888         IRQ_TYPE_LOWEST_LEVEL_LOW);
    889     irq_enable (InterruptNumber);
    890     return (AE_OK);
    891 }
    892 
    893 
    894 /******************************************************************************
    895  *
    896  * FUNCTION:    AcpiOsRemoveInterruptHandler
    897  *
    898  * PARAMETERS:  Handle              - Returned when handler was installed
    899  *
    900  * RETURN:      Status
    901  *
    902  * DESCRIPTION: Uninstalls an interrupt handler.
    903  *
    904  *****************************************************************************/
    905 
    906 ACPI_STATUS
    907 AcpiOsRemoveInterruptHandler (
    908     UINT32                  InterruptNumber,
    909     ACPI_OSD_HANDLER        ServiceRoutine)
    910 {
    911 
    912     LOG_DBG ("");
    913     irq_disable (InterruptNumber);
    914     return (AE_OK);
    915 }
    916 
    917 
    918 /******************************************************************************
    919  *
    920  * FUNCTION:    AcpiOsSignal
    921  *
    922  * PARAMETERS:  Function            - ACPICA signal function code
    923  *              Info                - Pointer to function-dependent structure
    924  *
    925  * RETURN:      Status
    926  *
    927  * DESCRIPTION: Miscellaneous functions. Example implementation only.
    928  *
    929  *****************************************************************************/
    930 
    931 ACPI_STATUS
    932 AcpiOsSignal (
    933     UINT32                  Function,
    934     void                    *Info)
    935 {
    936     switch (Function)
    937     {
    938     case ACPI_SIGNAL_FATAL:
    939         LOG_DBG ("ACPI_SIGNAL_FATAL error");
    940         break;
    941 
    942     case ACPI_SIGNAL_BREAKPOINT:
    943         LOG_DBG ("ACPI_SIGNAL_BREAKPOINT");
    944         break;
    945 
    946     default:
    947         break;
    948     }
    949 
    950     return (AE_OK);
    951 }
    952 
    953 
    954 /******************************************************************************
    955  *
    956  * FUNCTION:    Spinlock/Semaphore interfaces
    957  *
    958  * DESCRIPTION: Map these interfaces to semaphore interfaces
    959  *
    960  *****************************************************************************/
    961 
    962 #ifdef ACPI_SINGLE_THREADED
    963 ACPI_STATUS
    964 AcpiOsCreateLock (
    965     ACPI_SPINLOCK           *OutHandle)
    966 {
    967     LOG_DBG ("");
    968 
    969     return (AE_OK);
    970 }
    971 
    972 void
    973 AcpiOsDeleteLock (
    974     ACPI_SPINLOCK           Handle)
    975 {
    976     LOG_DBG ("");
    977 }
    978 
    979 ACPI_CPU_FLAGS
    980 AcpiOsAcquireLock (
    981     ACPI_SPINLOCK           Handle)
    982 {
    983     LOG_DBG ("");
    984     return (0);
    985 }
    986 
    987 void
    988 AcpiOsReleaseLock (
    989     ACPI_SPINLOCK           Handle,
    990     ACPI_CPU_FLAGS          Flags)
    991 {
    992     LOG_DBG ("");
    993 }
    994 
    995 ACPI_STATUS
    996 AcpiOsCreateSemaphore (
    997     UINT32              MaxUnits,
    998     UINT32              InitialUnits,
    999     ACPI_HANDLE         *OutHandle)
   1000 {
   1001     *OutHandle = (ACPI_HANDLE) 1;
   1002     return (AE_OK);
   1003 }
   1004 
   1005 ACPI_STATUS
   1006 AcpiOsDeleteSemaphore (
   1007     ACPI_HANDLE         Handle)
   1008 {
   1009     return (AE_OK);
   1010 }
   1011 
   1012 ACPI_STATUS
   1013 AcpiOsWaitSemaphore (
   1014     ACPI_HANDLE         Handle,
   1015     UINT32              Units,
   1016     UINT16              Timeout)
   1017 {
   1018     return (AE_OK);
   1019 }
   1020 
   1021 ACPI_STATUS
   1022 AcpiOsSignalSemaphore (
   1023     ACPI_HANDLE         Handle,
   1024     UINT32              Units)
   1025 {
   1026     return (AE_OK);
   1027 }
   1028 
   1029 ACPI_THREAD_ID
   1030 AcpiOsGetThreadId (
   1031     void)
   1032 {
   1033     LOG_DBG ("");
   1034     return (1);
   1035 }
   1036 
   1037 ACPI_STATUS
   1038 AcpiOsExecute (
   1039     ACPI_EXECUTE_TYPE       Type,
   1040     ACPI_OSD_EXEC_CALLBACK  Function,
   1041     void                    *Context)
   1042 {
   1043     Function (Context);
   1044     return (AE_OK);
   1045 }
   1046 #endif
   1047