evmisc.c revision 126372
138494Sobrien/******************************************************************************
238494Sobrien *
338494Sobrien * Module Name: evmisc - Miscellaneous event manager support functions
438494Sobrien *              $Revision: 70 $
5119679Smbr *
638494Sobrien *****************************************************************************/
7119679Smbr
8119679Smbr/******************************************************************************
9119679Smbr *
10119679Smbr * 1. Copyright Notice
11119679Smbr *
12119679Smbr * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
13119679Smbr * All rights reserved.
14119679Smbr *
15119679Smbr * 2. License
16119679Smbr *
17119679Smbr * 2.1. This is your license from Intel Corp. under its intellectual property
18119679Smbr * rights.  You may have additional license terms from the party that provided
19119679Smbr * you this software, covering your right to use that party's intellectual
20119679Smbr * property rights.
21119679Smbr *
22119679Smbr * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23119679Smbr * copy of the source code appearing in this file ("Covered Code") an
24119679Smbr * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25119679Smbr * base code distributed originally by Intel ("Original Intel Code") to copy,
26119679Smbr * make derivatives, distribute, use and display any portion of the Covered
27119679Smbr * Code in any form, with the right to sublicense such rights; and
28119679Smbr *
29119679Smbr * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30119679Smbr * license (with the right to sublicense), under only those claims of Intel
31119679Smbr * patents that are infringed by the Original Intel Code, to make, use, sell,
32119679Smbr * offer to sell, and import the Covered Code and derivative works thereof
33119679Smbr * solely to the minimum extent necessary to exercise the above copyright
34119679Smbr * license, and in no event shall the patent license extend to any additions
35119679Smbr * to or modifications of the Original Intel Code.  No other license or right
36119679Smbr * is granted directly or by implication, estoppel or otherwise;
37119679Smbr *
38119679Smbr * The above copyright and patent license is granted only if the following
39119679Smbr * conditions are met:
40119679Smbr *
41119679Smbr * 3. Conditions
42119679Smbr *
43119679Smbr * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44119679Smbr * Redistribution of source code of any substantial portion of the Covered
45119679Smbr * Code or modification with rights to further distribute source must include
46119679Smbr * the above Copyright Notice, the above License, this list of Conditions,
47119679Smbr * and the following Disclaimer and Export Compliance provision.  In addition,
48119679Smbr * Licensee must cause all Covered Code to which Licensee contributes to
49119679Smbr * contain a file documenting the changes Licensee made to create that Covered
50119679Smbr * Code and the date of any change.  Licensee must include in that file the
51119679Smbr * documentation of any changes made by any predecessor Licensee.  Licensee
52119679Smbr * must include a prominent statement that the modification is derived,
53119679Smbr * directly or indirectly, from Original Intel Code.
54119679Smbr *
55119679Smbr * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56119679Smbr * Redistribution of source code of any substantial portion of the Covered
57119679Smbr * Code or modification without rights to further distribute source must
58119679Smbr * include the following Disclaimer and Export Compliance provision in the
59119679Smbr * documentation and/or other materials provided with distribution.  In
60119679Smbr * addition, Licensee may not authorize further sublicense of source of any
61119679Smbr * portion of the Covered Code, and must include terms to the effect that the
62119679Smbr * license from Licensee to its licensee is limited to the intellectual
63119679Smbr * property embodied in the software Licensee provides to its licensee, and
64119679Smbr * not to intellectual property embodied in modifications its licensee may
65119679Smbr * make.
66119679Smbr *
67119679Smbr * 3.3. Redistribution of Executable. Redistribution in executable form of any
68119679Smbr * substantial portion of the Covered Code or modification must reproduce the
69119679Smbr * above Copyright Notice, and the following Disclaimer and Export Compliance
70119679Smbr * provision in the documentation and/or other materials provided with the
71119679Smbr * distribution.
72119679Smbr *
73119679Smbr * 3.4. Intel retains all right, title, and interest in and to the Original
74119679Smbr * Intel Code.
75119679Smbr *
76119679Smbr * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77119679Smbr * Intel shall be used in advertising or otherwise to promote the sale, use or
78119679Smbr * other dealings in products derived from or relating to the Covered Code
79119679Smbr * without prior written authorization from Intel.
80119679Smbr *
81119679Smbr * 4. Disclaimer and Export Compliance
82119679Smbr *
83119679Smbr * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84119679Smbr * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85119679Smbr * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86119679Smbr * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87119679Smbr * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88119679Smbr * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89119679Smbr * PARTICULAR PURPOSE.
90119679Smbr *
91119679Smbr * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92119679Smbr * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93119679Smbr * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94119679Smbr * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95119679Smbr * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96119679Smbr * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97119679Smbr * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98119679Smbr * LIMITED REMEDY.
99119679Smbr *
100119679Smbr * 4.3. Licensee shall not export, either directly or indirectly, any of this
101119679Smbr * software or system incorporating such software without first obtaining any
102119679Smbr * required license or other approval from the U. S. Department of Commerce or
103119679Smbr * any other agency or department of the United States Government.  In the
104119679Smbr * event Licensee exports any such software from the United States or
105119679Smbr * re-exports any such software from a foreign destination, Licensee shall
106119679Smbr * ensure that the distribution and export/re-export of the software is in
107119679Smbr * compliance with all laws, regulations, orders, or other restrictions of the
108119679Smbr * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109119679Smbr * any of its subsidiaries will export/re-export any technical data, process,
110119679Smbr * software, or service, directly or indirectly, to any country for which the
11138494Sobrien * United States government or any agency thereof requires an export license,
11238494Sobrien * other governmental approval, or letter of assurance, without first obtaining
11338494Sobrien * such license, approval or letter.
11438494Sobrien *
11538494Sobrien *****************************************************************************/
11638494Sobrien
11742629Sobrien#include "acpi.h"
118119679Smbr#include "acevents.h"
11942629Sobrien#include "acnamesp.h"
12038494Sobrien#include "acinterp.h"
12142629Sobrien
12238494Sobrien#define _COMPONENT          ACPI_EVENTS
12338494Sobrien        ACPI_MODULE_NAME    ("evmisc")
12438494Sobrien
12538494Sobrien
12638494Sobrien/*******************************************************************************
12738494Sobrien *
128119679Smbr * FUNCTION:    AcpiEvIsNotifyObject
129119679Smbr *
130119679Smbr * PARAMETERS:  Node            - Node to check
13138494Sobrien *
13238494Sobrien * RETURN:      TRUE if notifies allowed on this object
13338494Sobrien *
13438494Sobrien * DESCRIPTION: Check type of node for a object that supports notifies.
13538494Sobrien *
13638494Sobrien *              TBD: This could be replaced by a flag bit in the node.
13738494Sobrien *
13838494Sobrien ******************************************************************************/
13938494Sobrien
14038494SobrienBOOLEAN
14138494SobrienAcpiEvIsNotifyObject (
14238494Sobrien    ACPI_NAMESPACE_NODE     *Node)
14338494Sobrien{
14438494Sobrien    switch (Node->Type)
145119679Smbr    {
14638494Sobrien    case ACPI_TYPE_DEVICE:
14738494Sobrien    case ACPI_TYPE_PROCESSOR:
14838494Sobrien    case ACPI_TYPE_POWER:
14938494Sobrien    case ACPI_TYPE_THERMAL:
15038494Sobrien        /*
15138494Sobrien         * These are the ONLY objects that can receive ACPI notifications
15238494Sobrien         */
15338494Sobrien        return (TRUE);
15438494Sobrien
15538494Sobrien    default:
15638494Sobrien        return (FALSE);
15738494Sobrien    }
15838494Sobrien}
15938494Sobrien
16038494Sobrien
16138494Sobrien/*******************************************************************************
16238494Sobrien *
16338494Sobrien * FUNCTION:    AcpiEvQueueNotifyRequest
164 *
165 * PARAMETERS:
166 *
167 * RETURN:      None.
168 *
169 * DESCRIPTION: Dispatch a device notification event to a previously
170 *              installed handler.
171 *
172 ******************************************************************************/
173
174ACPI_STATUS
175AcpiEvQueueNotifyRequest (
176    ACPI_NAMESPACE_NODE     *Node,
177    UINT32                  NotifyValue)
178{
179    ACPI_OPERAND_OBJECT     *ObjDesc;
180    ACPI_OPERAND_OBJECT     *HandlerObj = NULL;
181    ACPI_GENERIC_STATE      *NotifyInfo;
182    ACPI_STATUS             Status = AE_OK;
183
184
185    ACPI_FUNCTION_NAME ("EvQueueNotifyRequest");
186
187
188    /*
189     * For value 1 (Ejection Request), some device method may need to be run.
190     * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need to be run.
191     * For value 0x80 (Status Change) on the power button or sleep button,
192     * initiate soft-off or sleep operation?
193     */
194    ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
195        "Dispatching Notify(%X) on node %p\n", NotifyValue, Node));
196
197    switch (NotifyValue)
198    {
199    case 0:
200        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Re-enumerate Devices\n"));
201        break;
202
203    case 1:
204        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Ejection Request\n"));
205        break;
206
207    case 2:
208        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Device Wake\n"));
209        break;
210
211    case 0x80:
212        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Status Change\n"));
213        break;
214
215    default:
216        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Unknown Notify Value: %X \n", NotifyValue));
217        break;
218    }
219
220    /*
221     * Get the notify object attached to the NS Node
222     */
223    ObjDesc = AcpiNsGetAttachedObject (Node);
224    if (ObjDesc)
225    {
226        /* We have the notify object, Get the right handler */
227
228        switch (Node->Type)
229        {
230        case ACPI_TYPE_DEVICE:
231        case ACPI_TYPE_THERMAL:
232        case ACPI_TYPE_PROCESSOR:
233        case ACPI_TYPE_POWER:
234
235            if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
236            {
237                HandlerObj = ObjDesc->CommonNotify.SystemNotify;
238            }
239            else
240            {
241                HandlerObj = ObjDesc->CommonNotify.DeviceNotify;
242            }
243            break;
244
245        default:
246            /* All other types are not supported */
247            return (AE_TYPE);
248        }
249    }
250
251    /* If there is any handler to run, schedule the dispatcher */
252
253    if ((AcpiGbl_SystemNotify.Handler && (NotifyValue <= ACPI_MAX_SYS_NOTIFY)) ||
254        (AcpiGbl_DeviceNotify.Handler && (NotifyValue > ACPI_MAX_SYS_NOTIFY))  ||
255        HandlerObj)
256    {
257        NotifyInfo = AcpiUtCreateGenericState ();
258        if (!NotifyInfo)
259        {
260            return (AE_NO_MEMORY);
261        }
262
263        NotifyInfo->Common.DataType   = ACPI_DESC_TYPE_STATE_NOTIFY;
264        NotifyInfo->Notify.Node       = Node;
265        NotifyInfo->Notify.Value      = (UINT16) NotifyValue;
266        NotifyInfo->Notify.HandlerObj = HandlerObj;
267
268        Status = AcpiOsQueueForExecution (OSD_PRIORITY_HIGH,
269                        AcpiEvNotifyDispatch, NotifyInfo);
270        if (ACPI_FAILURE (Status))
271        {
272            AcpiUtDeleteGenericState (NotifyInfo);
273        }
274    }
275
276    if (!HandlerObj)
277    {
278        /* There is no per-device notify handler for this device */
279
280        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
281            "No notify handler for [%4.4s] node %p\n",
282            AcpiUtGetNodeName (Node), Node));
283    }
284
285    return (Status);
286}
287
288
289/*******************************************************************************
290 *
291 * FUNCTION:    AcpiEvNotifyDispatch
292 *
293 * PARAMETERS:
294 *
295 * RETURN:      None.
296 *
297 * DESCRIPTION: Dispatch a device notification event to a previously
298 *              installed handler.
299 *
300 ******************************************************************************/
301
302void ACPI_SYSTEM_XFACE
303AcpiEvNotifyDispatch (
304    void                    *Context)
305{
306    ACPI_GENERIC_STATE      *NotifyInfo = (ACPI_GENERIC_STATE *) Context;
307    ACPI_NOTIFY_HANDLER     GlobalHandler = NULL;
308    void                    *GlobalContext = NULL;
309    ACPI_OPERAND_OBJECT     *HandlerObj;
310
311
312    ACPI_FUNCTION_ENTRY ();
313
314
315    /*
316     * We will invoke a global notify handler if installed.
317     * This is done _before_ we invoke the per-device handler attached to the device.
318     */
319    if (NotifyInfo->Notify.Value <= ACPI_MAX_SYS_NOTIFY)
320    {
321        /* Global system notification handler */
322
323        if (AcpiGbl_SystemNotify.Handler)
324        {
325            GlobalHandler = AcpiGbl_SystemNotify.Handler;
326            GlobalContext = AcpiGbl_SystemNotify.Context;
327        }
328    }
329    else
330    {
331        /* Global driver notification handler */
332
333        if (AcpiGbl_DeviceNotify.Handler)
334        {
335            GlobalHandler = AcpiGbl_DeviceNotify.Handler;
336            GlobalContext = AcpiGbl_DeviceNotify.Context;
337        }
338    }
339
340    /* Invoke the system handler first, if present */
341
342    if (GlobalHandler)
343    {
344        GlobalHandler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, GlobalContext);
345    }
346
347    /* Now invoke the per-device handler, if present */
348
349    HandlerObj = NotifyInfo->Notify.HandlerObj;
350    if (HandlerObj)
351    {
352        HandlerObj->Notify.Handler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value,
353                        HandlerObj->Notify.Context);
354    }
355
356    /* All done with the info object */
357
358    AcpiUtDeleteGenericState (NotifyInfo);
359}
360
361
362/*******************************************************************************
363 *
364 * FUNCTION:    AcpiEvGlobalLockThread
365 *
366 * RETURN:      None
367 *
368 * DESCRIPTION: Invoked by SCI interrupt handler upon acquisition of the
369 *              Global Lock.  Simply signal all threads that are waiting
370 *              for the lock.
371 *
372 ******************************************************************************/
373
374static void ACPI_SYSTEM_XFACE
375AcpiEvGlobalLockThread (
376    void                    *Context)
377{
378    ACPI_STATUS             Status;
379
380
381    /* Signal threads that are waiting for the lock */
382
383    if (AcpiGbl_GlobalLockThreadCount)
384    {
385        /* Send sufficient units to the semaphore */
386
387        Status = AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore,
388                                AcpiGbl_GlobalLockThreadCount);
389        if (ACPI_FAILURE (Status))
390        {
391            ACPI_REPORT_ERROR (("Could not signal Global Lock semaphore\n"));
392        }
393    }
394}
395
396
397/*******************************************************************************
398 *
399 * FUNCTION:    AcpiEvGlobalLockHandler
400 *
401 * RETURN:      Status
402 *
403 * DESCRIPTION: Invoked directly from the SCI handler when a global lock
404 *              release interrupt occurs.  Grab the global lock and queue
405 *              the global lock thread for execution
406 *
407 ******************************************************************************/
408
409static UINT32
410AcpiEvGlobalLockHandler (
411    void                    *Context)
412{
413    BOOLEAN                 Acquired = FALSE;
414    ACPI_STATUS             Status;
415
416
417    /*
418     * Attempt to get the lock
419     * If we don't get it now, it will be marked pending and we will
420     * take another interrupt when it becomes free.
421     */
422    ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Acquired);
423    if (Acquired)
424    {
425        /* Got the lock, now wake all threads waiting for it */
426
427        AcpiGbl_GlobalLockAcquired = TRUE;
428
429        /* Run the Global Lock thread which will signal all waiting threads */
430
431        Status = AcpiOsQueueForExecution (OSD_PRIORITY_HIGH,
432                        AcpiEvGlobalLockThread, Context);
433        if (ACPI_FAILURE (Status))
434        {
435            ACPI_REPORT_ERROR (("Could not queue Global Lock thread, %s\n",
436                AcpiFormatException (Status)));
437
438            return (ACPI_INTERRUPT_NOT_HANDLED);
439        }
440    }
441
442    return (ACPI_INTERRUPT_HANDLED);
443}
444
445
446/*******************************************************************************
447 *
448 * FUNCTION:    AcpiEvInitGlobalLockHandler
449 *
450 * RETURN:      Status
451 *
452 * DESCRIPTION: Install a handler for the global lock release event
453 *
454 ******************************************************************************/
455
456ACPI_STATUS
457AcpiEvInitGlobalLockHandler (void)
458{
459    ACPI_STATUS             Status;
460
461
462    ACPI_FUNCTION_TRACE ("EvInitGlobalLockHandler");
463
464
465    AcpiGbl_GlobalLockPresent = TRUE;
466    Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL,
467                                            AcpiEvGlobalLockHandler, NULL);
468
469    /*
470     * If the global lock does not exist on this platform, the attempt
471     * to enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick)
472     * Map to AE_OK, but mark global lock as not present.
473     * Any attempt to actually use the global lock will be flagged
474     * with an error.
475     */
476    if (Status == AE_NO_HARDWARE_RESPONSE)
477    {
478        AcpiGbl_GlobalLockPresent = FALSE;
479        Status = AE_OK;
480    }
481
482    return_ACPI_STATUS (Status);
483}
484
485
486/******************************************************************************
487 *
488 * FUNCTION:    AcpiEvAcquireGlobalLock
489 *
490 * RETURN:      Status
491 *
492 * DESCRIPTION: Attempt to gain ownership of the Global Lock.
493 *
494 *****************************************************************************/
495
496ACPI_STATUS
497AcpiEvAcquireGlobalLock (
498    UINT16                  Timeout)
499{
500    ACPI_STATUS             Status = AE_OK;
501    BOOLEAN                 Acquired = FALSE;
502
503
504    ACPI_FUNCTION_TRACE ("EvAcquireGlobalLock");
505
506
507#ifndef ACPI_APPLICATION
508    /* Make sure that we actually have a global lock */
509
510    if (!AcpiGbl_GlobalLockPresent)
511    {
512        return_ACPI_STATUS (AE_NO_GLOBAL_LOCK);
513    }
514#endif
515
516    /* One more thread wants the global lock */
517
518    AcpiGbl_GlobalLockThreadCount++;
519
520    /* If we (OS side vs. BIOS side) have the hardware lock already, we are done */
521
522    if (AcpiGbl_GlobalLockAcquired)
523    {
524        return_ACPI_STATUS (AE_OK);
525    }
526
527    /* We must acquire the actual hardware lock */
528
529    ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Acquired);
530    if (Acquired)
531    {
532       /* We got the lock */
533
534        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired the HW Global Lock\n"));
535
536        AcpiGbl_GlobalLockAcquired = TRUE;
537        return_ACPI_STATUS (AE_OK);
538    }
539
540    /*
541     * Did not get the lock.  The pending bit was set above, and we must now
542     * wait until we get the global lock released interrupt.
543     */
544    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n"));
545
546    /*
547     * Acquire the global lock semaphore first.
548     * Since this wait will block, we must release the interpreter
549     */
550    Status = AcpiExSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore,
551                                            Timeout);
552    return_ACPI_STATUS (Status);
553}
554
555
556/*******************************************************************************
557 *
558 * FUNCTION:    AcpiEvReleaseGlobalLock
559 *
560 * DESCRIPTION: Releases ownership of the Global Lock.
561 *
562 ******************************************************************************/
563
564ACPI_STATUS
565AcpiEvReleaseGlobalLock (void)
566{
567    BOOLEAN                 Pending = FALSE;
568    ACPI_STATUS             Status = AE_OK;
569
570
571    ACPI_FUNCTION_TRACE ("EvReleaseGlobalLock");
572
573
574    if (!AcpiGbl_GlobalLockThreadCount)
575    {
576        ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n"));
577        return_ACPI_STATUS (AE_NOT_ACQUIRED);
578    }
579
580    /* One fewer thread has the global lock */
581
582    AcpiGbl_GlobalLockThreadCount--;
583    if (AcpiGbl_GlobalLockThreadCount)
584    {
585        /* There are still some threads holding the lock, cannot release */
586
587        return_ACPI_STATUS (AE_OK);
588    }
589
590    /*
591     * No more threads holding lock, we can do the actual hardware
592     * release
593     */
594    ACPI_RELEASE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Pending);
595    AcpiGbl_GlobalLockAcquired = FALSE;
596
597    /*
598     * If the pending bit was set, we must write GBL_RLS to the control
599     * register
600     */
601    if (Pending)
602    {
603        Status = AcpiSetRegister (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1, ACPI_MTX_LOCK);
604    }
605
606    return_ACPI_STATUS (Status);
607}
608
609
610/******************************************************************************
611 *
612 * FUNCTION:    AcpiEvTerminate
613 *
614 * PARAMETERS:  none
615 *
616 * RETURN:      none
617 *
618 * DESCRIPTION: Disable events and free memory allocated for table storage.
619 *
620 ******************************************************************************/
621
622void
623AcpiEvTerminate (void)
624{
625    ACPI_NATIVE_UINT        i;
626    ACPI_STATUS             Status;
627
628
629    ACPI_FUNCTION_TRACE ("EvTerminate");
630
631
632    if (AcpiGbl_EventsInitialized)
633    {
634        /*
635         * Disable all event-related functionality.
636         * In all cases, on error, print a message but obviously we don't abort.
637         */
638
639        /* Disable all fixed events */
640
641        for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
642        {
643            Status = AcpiDisableEvent ((UINT32) i, 0);
644            if (ACPI_FAILURE (Status))
645            {
646                ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not disable fixed event %d\n", (UINT32) i));
647            }
648        }
649
650        /* Disable all GPEs in all GPE blocks */
651
652        Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock);
653
654        /* Remove SCI handler */
655
656        Status = AcpiEvRemoveSciHandler ();
657        if (ACPI_FAILURE(Status))
658        {
659            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not remove SCI handler\n"));
660        }
661    }
662
663    /* Return to original mode if necessary */
664
665    if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY)
666    {
667        Status = AcpiDisable ();
668        if (ACPI_FAILURE (Status))
669        {
670            ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "AcpiDisable failed\n"));
671        }
672    }
673    return_VOID;
674}
675
676