sys/contrib/dev/acpica-unix/tools/acpiexec/aehandlers.c
ACPI_STATUS
AeInstallEarlyHandlers (
    void)
{
    ACPI_STATUS             Status;
    UINT32                  i;
    ACPI_HANDLE             Handle;


    ACPI_FUNCTION_ENTRY ();


    Status = AcpiInstallInterfaceHandler (AeInterfaceHandler);
    if (ACPI_FAILURE (Status))
    {
        printf ("Could not install interface handler, %s\n",
            AcpiFormatException (Status));
    }

    Status = AcpiInstallTableHandler (AeTableHandler, NULL);
    if (ACPI_FAILURE (Status))
    {
        printf ("Could not install table handler, %s\n",
            AcpiFormatException (Status));
    }

    Status = AcpiInstallExceptionHandler (AeExceptionHandler);
    if (ACPI_FAILURE (Status))
    {
        printf ("Could not install exception handler, %s\n",
            AcpiFormatException (Status));
    }

    /* Install global notify handler */

    Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
                                        AeNotifyHandler, NULL);
    if (ACPI_FAILURE (Status))
    {
        printf ("Could not install a global notify handler, %s\n",
            AcpiFormatException (Status));
    }

    Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY,
                                        AeDeviceNotifyHandler, NULL);
    if (ACPI_FAILURE (Status))
    {
        printf ("Could not install a global notify handler, %s\n",
            AcpiFormatException (Status));
    }

    Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
    if (ACPI_SUCCESS (Status))
    {
        Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
                                            AeNotifyHandler, NULL);
        if (ACPI_FAILURE (Status))
        {
            printf ("Could not install a notify handler, %s\n",
                AcpiFormatException (Status));
        }

        Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
                                            AeNotifyHandler);
        if (ACPI_FAILURE (Status))
        {
            printf ("Could not remove a notify handler, %s\n",
                AcpiFormatException (Status));
        }

        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
                                            AeNotifyHandler, NULL);
        AE_CHECK_OK (AcpiInstallNotifyHandler, Status);

        Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
                                            AeNotifyHandler);
        AE_CHECK_OK (AcpiRemoveNotifyHandler, Status);

        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
                                            AeNotifyHandler, NULL);
        if (ACPI_FAILURE (Status))
        {
            printf ("Could not install a notify handler, %s\n",
                AcpiFormatException (Status));
        }

        Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
        AE_CHECK_OK (AcpiAttachData, Status);

        Status = AcpiDetachData (Handle, AeAttachedDataHandler);
        AE_CHECK_OK (AcpiDetachData, Status);

        Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
        AE_CHECK_OK (AcpiAttachData, Status);
    }
    else
    {
        printf ("No _SB_ found, %s\n", AcpiFormatException (Status));
    }


    /*
     * Install handlers that will override the default handlers for some of
     * the space IDs.
     */
    for (i = 0; i < ACPI_ARRAY_LENGTH (DefaultSpaceIdList); i++)
    {
        /* Install handler at the root object */

        Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode,
                    DefaultSpaceIdList[i], AeRegionHandler,
                    AeRegionInit, NULL);
        if (ACPI_FAILURE (Status))
        {
            ACPI_EXCEPTION ((AE_INFO, Status,
                "Could not install a default OpRegion handler for %s space(%u)",
                AcpiUtGetRegionName ((UINT8) DefaultSpaceIdList[i]),
                DefaultSpaceIdList[i]));
            return (Status);
        }
    }

    /*
     * Initialize the global Region Handler space
     * MCW 3/23/00
     */
    AeRegions.NumberOfRegions = 0;
    AeRegions.RegionList = NULL;
    return (Status);
}
/******************************************************************************
 *
 * FUNCTION:    AeInstallEarlyHandlers
 *
 * PARAMETERS:  None
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Install handlers for the AcpiExec utility.
 *
 * Notes:       Don't install handler for PCI_Config, we want to use the
 *              default handler to exercise that code.
 *
 *****************************************************************************/


Status

Install handlers for the AcpiExec utility.

Don't install handler for PCI_Config, we want to use the
default handler to exercise that code.
Status Install handlers for the AcpiExec utility . Don ' t install handler for PCI_Config we want to use the default handler to exercise that code .
ACPI_STATUS
AeInstallEarlyHandlers (
    void)
{
    ACPI_STATUS             Status;
    UINT32                  i;
    ACPI_HANDLE             Handle;
    ACPI_FUNCTION_ENTRY ();
    Status = AcpiInstallInterfaceHandler (AeInterfaceHandler);
    if (ACPI_FAILURE (Status))
    {
        printf ("Could not install interface handler, %s\n",
            AcpiFormatException (Status));
    }
    Status = AcpiInstallTableHandler (AeTableHandler, NULL);
    if (ACPI_FAILURE (Status))
    {
        printf ("Could not install table handler, %s\n",
            AcpiFormatException (Status));
    }
    Status = AcpiInstallExceptionHandler (AeExceptionHandler);
    if (ACPI_FAILURE (Status))
    {
        printf ("Could not install exception handler, %s\n",
            AcpiFormatException (Status));
    }
    Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
                                        AeNotifyHandler, NULL);
    if (ACPI_FAILURE (Status))
    {
        printf ("Could not install a global notify handler, %s\n",
            AcpiFormatException (Status));
    }
    Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY,
                                        AeDeviceNotifyHandler, NULL);
    if (ACPI_FAILURE (Status))
    {
        printf ("Could not install a global notify handler, %s\n",
            AcpiFormatException (Status));
    }
    Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
    if (ACPI_SUCCESS (Status))
    {
        Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
                                            AeNotifyHandler, NULL);
        if (ACPI_FAILURE (Status))
        {
            printf ("Could not install a notify handler, %s\n",
                AcpiFormatException (Status));
        }
        Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
                                            AeNotifyHandler);
        if (ACPI_FAILURE (Status))
        {
            printf ("Could not remove a notify handler, %s\n",
                AcpiFormatException (Status));
        }
        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
                                            AeNotifyHandler, NULL);
        AE_CHECK_OK (AcpiInstallNotifyHandler, Status);
        Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
                                            AeNotifyHandler);
        AE_CHECK_OK (AcpiRemoveNotifyHandler, Status);
        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
                                            AeNotifyHandler, NULL);
        if (ACPI_FAILURE (Status))
        {
            printf ("Could not install a notify handler, %s\n",
                AcpiFormatException (Status));
        }
        Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
        AE_CHECK_OK (AcpiAttachData, Status);
        Status = AcpiDetachData (Handle, AeAttachedDataHandler);
        AE_CHECK_OK (AcpiDetachData, Status);
        Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
        AE_CHECK_OK (AcpiAttachData, Status);
    }
    else
    {
        printf ("No _SB_ found, %s\n", AcpiFormatException (Status));
    }
    for (i = 0; i < ACPI_ARRAY_LENGTH (DefaultSpaceIdList); i++)
    {
        Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode,
                    DefaultSpaceIdList[i], AeRegionHandler,
                    AeRegionInit, NULL);
        if (ACPI_FAILURE (Status))
        {
            ACPI_EXCEPTION ((AE_INFO, Status,
                "Could not install a default OpRegion handler for %s space(%u)",
                AcpiUtGetRegionName ((UINT8) DefaultSpaceIdList[i]),
                DefaultSpaceIdList[i]));
            return (Status);
        }
    }
    AeRegions.NumberOfRegions = 0;
    AeRegions.RegionList = NULL;
    return (Status);
}
ACPI_STATUS AeInstallEarlyHandlers ( void ) { ACPI_STATUS Status ; UINT32 i ; ACPI_HANDLE Handle ; ACPI_FUNCTION_ENTRY ( ) ; Status = AcpiInstallInterfaceHandler ( AeInterfaceHandler ) ; if ( ACPI_FAILURE ( Status ) ) { printf ( " \n " , AcpiFormatException ( Status ) ) ; } Status = AcpiInstallTableHandler ( AeTableHandler , NULL ) ; if ( ACPI_FAILURE ( Status ) ) { printf ( " \n " , AcpiFormatException ( Status ) ) ; } Status = AcpiInstallExceptionHandler ( AeExceptionHandler ) ; if ( ACPI_FAILURE ( Status ) ) { printf ( " \n " , AcpiFormatException ( Status ) ) ; } Status = AcpiInstallNotifyHandler ( ACPI_ROOT_OBJECT , ACPI_SYSTEM_NOTIFY , AeNotifyHandler , NULL ) ; if ( ACPI_FAILURE ( Status ) ) { printf ( " \n " , AcpiFormatException ( Status ) ) ; } Status = AcpiInstallNotifyHandler ( ACPI_ROOT_OBJECT , ACPI_DEVICE_NOTIFY , AeDeviceNotifyHandler , NULL ) ; if ( ACPI_FAILURE ( Status ) ) { printf ( " \n " , AcpiFormatException ( Status ) ) ; } Status = AcpiGetHandle ( NULL , " \\ " , & Handle ) ; if ( ACPI_SUCCESS ( Status ) ) { Status = AcpiInstallNotifyHandler ( Handle , ACPI_SYSTEM_NOTIFY , AeNotifyHandler , NULL ) ; if ( ACPI_FAILURE ( Status ) ) { printf ( " \n " , AcpiFormatException ( Status ) ) ; } Status = AcpiRemoveNotifyHandler ( Handle , ACPI_SYSTEM_NOTIFY , AeNotifyHandler ) ; if ( ACPI_FAILURE ( Status ) ) { printf ( " \n " , AcpiFormatException ( Status ) ) ; } Status = AcpiInstallNotifyHandler ( Handle , ACPI_ALL_NOTIFY , AeNotifyHandler , NULL ) ; AE_CHECK_OK ( AcpiInstallNotifyHandler , Status ) ; Status = AcpiRemoveNotifyHandler ( Handle , ACPI_ALL_NOTIFY , AeNotifyHandler ) ; AE_CHECK_OK ( AcpiRemoveNotifyHandler , Status ) ; Status = AcpiInstallNotifyHandler ( Handle , ACPI_ALL_NOTIFY , AeNotifyHandler , NULL ) ; if ( ACPI_FAILURE ( Status ) ) { printf ( " \n " , AcpiFormatException ( Status ) ) ; } Status = AcpiAttachData ( Handle , AeAttachedDataHandler , Handle ) ; AE_CHECK_OK ( AcpiAttachData , Status ) ; Status = AcpiDetachData ( Handle , AeAttachedDataHandler ) ; AE_CHECK_OK ( AcpiDetachData , Status ) ; Status = AcpiAttachData ( Handle , AeAttachedDataHandler , Handle ) ; AE_CHECK_OK ( AcpiAttachData , Status ) ; } else { printf ( " \n " , AcpiFormatException ( Status ) ) ; } for ( i = 0 ; i < ACPI_ARRAY_LENGTH ( DefaultSpaceIdList ) ; i ++ ) { Status = AcpiInstallAddressSpaceHandler ( AcpiGbl_RootNode , DefaultSpaceIdList [ i ] , AeRegionHandler , AeRegionInit , NULL ) ; if ( ACPI_FAILURE ( Status ) ) { ACPI_EXCEPTION ( ( AE_INFO , Status , " " , AcpiUtGetRegionName ( ( UINT8 ) DefaultSpaceIdList [ i ] ) , DefaultSpaceIdList [ i ] ) ) ; return ( Status ) ; } } AeRegions . NumberOfRegions = 0 ; AeRegions . RegionList = NULL ; return ( Status ) ; }
FUNCTION:    AeInstallEarlyHandlers
 PARAMETERS:  None
FUNCTION : AeInstallEarlyHandlers PARAMETERS : None
/* Install global notify handler */ /*
     * Install handlers that will override the default handlers for some of
     * the space IDs.
     */ /* Install handler at the root object */ /*
     * Initialize the global Region Handler space
     * MCW 3/23/00
     */