Deleted Added
full compact
utxface.c (231844) utxface.c (239340)
1/******************************************************************************
2 *
1/******************************************************************************
2 *
3 * Module Name: utxface - External interfaces for "global" ACPI functions
3 * Module Name: utxface - External interfaces, miscellaneous utility functions
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without

--- 29 unchanged lines hidden (view full) ---

41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#define __UTXFACE_C__
46
47#include <contrib/dev/acpica/include/acpi.h>
48#include <contrib/dev/acpica/include/accommon.h>
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without

--- 29 unchanged lines hidden (view full) ---

41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44
45#define __UTXFACE_C__
46
47#include <contrib/dev/acpica/include/acpi.h>
48#include <contrib/dev/acpica/include/accommon.h>
49#include <contrib/dev/acpica/include/acevents.h>
50#include <contrib/dev/acpica/include/acnamesp.h>
51#include <contrib/dev/acpica/include/acdebug.h>
49#include <contrib/dev/acpica/include/acdebug.h>
52#include <contrib/dev/acpica/include/actables.h>
53
54#define _COMPONENT ACPI_UTILITIES
55 ACPI_MODULE_NAME ("utxface")
56
57
50
51#define _COMPONENT ACPI_UTILITIES
52 ACPI_MODULE_NAME ("utxface")
53
54
58#ifndef ACPI_ASL_COMPILER
59/*******************************************************************************
60 *
55/*******************************************************************************
56 *
61 * FUNCTION: AcpiInitializeSubsystem
62 *
63 * PARAMETERS: None
64 *
65 * RETURN: Status
66 *
67 * DESCRIPTION: Initializes all global variables. This is the first function
68 * called, so any early initialization belongs here.
69 *
70 ******************************************************************************/
71
72ACPI_STATUS
73AcpiInitializeSubsystem (
74 void)
75{
76 ACPI_STATUS Status;
77
78
79 ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);
80
81
82 AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
83 ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
84
85 /* Initialize the OS-Dependent layer */
86
87 Status = AcpiOsInitialize ();
88 if (ACPI_FAILURE (Status))
89 {
90 ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));
91 return_ACPI_STATUS (Status);
92 }
93
94 /* Initialize all globals used by the subsystem */
95
96 Status = AcpiUtInitGlobals ();
97 if (ACPI_FAILURE (Status))
98 {
99 ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));
100 return_ACPI_STATUS (Status);
101 }
102
103 /* Create the default mutex objects */
104
105 Status = AcpiUtMutexInitialize ();
106 if (ACPI_FAILURE (Status))
107 {
108 ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));
109 return_ACPI_STATUS (Status);
110 }
111
112 /*
113 * Initialize the namespace manager and
114 * the root of the namespace tree
115 */
116 Status = AcpiNsRootInitialize ();
117 if (ACPI_FAILURE (Status))
118 {
119 ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));
120 return_ACPI_STATUS (Status);
121 }
122
123 /* Initialize the global OSI interfaces list with the static names */
124
125 Status = AcpiUtInitializeInterfaces ();
126 if (ACPI_FAILURE (Status))
127 {
128 ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization"));
129 return_ACPI_STATUS (Status);
130 }
131
132 /* If configured, initialize the AML debugger */
133
134 ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ());
135 return_ACPI_STATUS (Status);
136}
137
138ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem)
139
140
141/*******************************************************************************
142 *
143 * FUNCTION: AcpiEnableSubsystem
144 *
145 * PARAMETERS: Flags - Init/enable Options
146 *
147 * RETURN: Status
148 *
149 * DESCRIPTION: Completes the subsystem initialization including hardware.
150 * Puts system into ACPI mode if it isn't already.
151 *
152 ******************************************************************************/
153
154ACPI_STATUS
155AcpiEnableSubsystem (
156 UINT32 Flags)
157{
158 ACPI_STATUS Status = AE_OK;
159
160
161 ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
162
163
164#if (!ACPI_REDUCED_HARDWARE)
165
166 /* Enable ACPI mode */
167
168 if (!(Flags & ACPI_NO_ACPI_ENABLE))
169 {
170 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
171
172 AcpiGbl_OriginalMode = AcpiHwGetMode();
173
174 Status = AcpiEnable ();
175 if (ACPI_FAILURE (Status))
176 {
177 ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
178 return_ACPI_STATUS (Status);
179 }
180 }
181
182 /*
183 * Obtain a permanent mapping for the FACS. This is required for the
184 * Global Lock and the Firmware Waking Vector
185 */
186 Status = AcpiTbInitializeFacs ();
187 if (ACPI_FAILURE (Status))
188 {
189 ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
190 return_ACPI_STATUS (Status);
191 }
192
193#endif /* !ACPI_REDUCED_HARDWARE */
194
195 /*
196 * Install the default OpRegion handlers. These are installed unless
197 * other handlers have already been installed via the
198 * InstallAddressSpaceHandler interface.
199 */
200 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
201 {
202 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
203 "[Init] Installing default address space handlers\n"));
204
205 Status = AcpiEvInstallRegionHandlers ();
206 if (ACPI_FAILURE (Status))
207 {
208 return_ACPI_STATUS (Status);
209 }
210 }
211
212#if (!ACPI_REDUCED_HARDWARE)
213 /*
214 * Initialize ACPI Event handling (Fixed and General Purpose)
215 *
216 * Note1: We must have the hardware and events initialized before we can
217 * execute any control methods safely. Any control method can require
218 * ACPI hardware support, so the hardware must be fully initialized before
219 * any method execution!
220 *
221 * Note2: Fixed events are initialized and enabled here. GPEs are
222 * initialized, but cannot be enabled until after the hardware is
223 * completely initialized (SCI and GlobalLock activated) and the various
224 * initialization control methods are run (_REG, _STA, _INI) on the
225 * entire namespace.
226 */
227 if (!(Flags & ACPI_NO_EVENT_INIT))
228 {
229 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
230 "[Init] Initializing ACPI events\n"));
231
232 Status = AcpiEvInitializeEvents ();
233 if (ACPI_FAILURE (Status))
234 {
235 return_ACPI_STATUS (Status);
236 }
237 }
238
239 /*
240 * Install the SCI handler and Global Lock handler. This completes the
241 * hardware initialization.
242 */
243 if (!(Flags & ACPI_NO_HANDLER_INIT))
244 {
245 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
246 "[Init] Installing SCI/GL handlers\n"));
247
248 Status = AcpiEvInstallXruptHandlers ();
249 if (ACPI_FAILURE (Status))
250 {
251 return_ACPI_STATUS (Status);
252 }
253 }
254
255#endif /* !ACPI_REDUCED_HARDWARE */
256
257 return_ACPI_STATUS (Status);
258}
259
260ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem)
261
262
263/*******************************************************************************
264 *
265 * FUNCTION: AcpiInitializeObjects
266 *
267 * PARAMETERS: Flags - Init/enable Options
268 *
269 * RETURN: Status
270 *
271 * DESCRIPTION: Completes namespace initialization by initializing device
272 * objects and executing AML code for Regions, buffers, etc.
273 *
274 ******************************************************************************/
275
276ACPI_STATUS
277AcpiInitializeObjects (
278 UINT32 Flags)
279{
280 ACPI_STATUS Status = AE_OK;
281
282
283 ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
284
285
286 /*
287 * Run all _REG methods
288 *
289 * Note: Any objects accessed by the _REG methods will be automatically
290 * initialized, even if they contain executable AML (see the call to
291 * AcpiNsInitializeObjects below).
292 */
293 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
294 {
295 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
296 "[Init] Executing _REG OpRegion methods\n"));
297
298 Status = AcpiEvInitializeOpRegions ();
299 if (ACPI_FAILURE (Status))
300 {
301 return_ACPI_STATUS (Status);
302 }
303 }
304
305 /*
306 * Execute any module-level code that was detected during the table load
307 * phase. Although illegal since ACPI 2.0, there are many machines that
308 * contain this type of code. Each block of detected executable AML code
309 * outside of any control method is wrapped with a temporary control
310 * method object and placed on a global list. The methods on this list
311 * are executed below.
312 */
313 AcpiNsExecModuleCodeList ();
314
315 /*
316 * Initialize the objects that remain uninitialized. This runs the
317 * executable AML that may be part of the declaration of these objects:
318 * OperationRegions, BufferFields, Buffers, and Packages.
319 */
320 if (!(Flags & ACPI_NO_OBJECT_INIT))
321 {
322 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
323 "[Init] Completing Initialization of ACPI Objects\n"));
324
325 Status = AcpiNsInitializeObjects ();
326 if (ACPI_FAILURE (Status))
327 {
328 return_ACPI_STATUS (Status);
329 }
330 }
331
332 /*
333 * Initialize all device objects in the namespace. This runs the device
334 * _STA and _INI methods.
335 */
336 if (!(Flags & ACPI_NO_DEVICE_INIT))
337 {
338 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
339 "[Init] Initializing ACPI Devices\n"));
340
341 Status = AcpiNsInitializeDevices ();
342 if (ACPI_FAILURE (Status))
343 {
344 return_ACPI_STATUS (Status);
345 }
346 }
347
348 /*
349 * Empty the caches (delete the cached objects) on the assumption that
350 * the table load filled them up more than they will be at runtime --
351 * thus wasting non-paged memory.
352 */
353 Status = AcpiPurgeCachedObjects ();
354
355 AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
356 return_ACPI_STATUS (Status);
357}
358
359ACPI_EXPORT_SYMBOL (AcpiInitializeObjects)
360
361
362#endif
363
364/*******************************************************************************
365 *
366 * FUNCTION: AcpiTerminate
367 *
368 * PARAMETERS: None
369 *
370 * RETURN: Status
371 *
372 * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
373 *

--- 456 unchanged lines hidden (view full) ---

830
831 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
832 return (Overlaps);
833}
834
835ACPI_EXPORT_SYMBOL (AcpiCheckAddressRange)
836
837#endif /* !ACPI_ASL_COMPILER */
57 * FUNCTION: AcpiTerminate
58 *
59 * PARAMETERS: None
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
64 *

--- 456 unchanged lines hidden (view full) ---

521
522 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
523 return (Overlaps);
524}
525
526ACPI_EXPORT_SYMBOL (AcpiCheckAddressRange)
527
528#endif /* !ACPI_ASL_COMPILER */
529
530
531/*******************************************************************************
532 *
533 * FUNCTION: AcpiDecodePldBuffer
534 *
535 * PARAMETERS: InBuffer - Buffer returned by _PLD method
536 * Length - Length of the InBuffer
537 * ReturnBuffer - Where the decode buffer is returned
538 *
539 * RETURN: Status and the decoded _PLD buffer. User must deallocate
540 * the buffer via ACPI_FREE.
541 *
542 * DESCRIPTION: Decode the bit-packed buffer returned by the _PLD method into
543 * a local struct that is much more useful to an ACPI driver.
544 *
545 ******************************************************************************/
546
547ACPI_STATUS
548AcpiDecodePldBuffer (
549 UINT8 *InBuffer,
550 ACPI_SIZE Length,
551 ACPI_PLD_INFO **ReturnBuffer)
552{
553 ACPI_PLD_INFO *PldInfo;
554 UINT32 *Buffer = ACPI_CAST_PTR (UINT32, InBuffer);
555 UINT32 Dword;
556
557
558 /* Parameter validation */
559
560 if (!InBuffer || !ReturnBuffer || (Length < 16))
561 {
562 return (AE_BAD_PARAMETER);
563 }
564
565 PldInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PLD_INFO));
566 if (!PldInfo)
567 {
568 return (AE_NO_MEMORY);
569 }
570
571 /* First 32-bit DWord */
572
573 ACPI_MOVE_32_TO_32 (&Dword, &Buffer[0]);
574 PldInfo->Revision = ACPI_PLD_GET_REVISION (&Dword);
575 PldInfo->IgnoreColor = ACPI_PLD_GET_IGNORE_COLOR (&Dword);
576 PldInfo->Color = ACPI_PLD_GET_COLOR (&Dword);
577
578 /* Second 32-bit DWord */
579
580 ACPI_MOVE_32_TO_32 (&Dword, &Buffer[1]);
581 PldInfo->Width = ACPI_PLD_GET_WIDTH (&Dword);
582 PldInfo->Height = ACPI_PLD_GET_HEIGHT(&Dword);
583
584 /* Third 32-bit DWord */
585
586 ACPI_MOVE_32_TO_32 (&Dword, &Buffer[2]);
587 PldInfo->UserVisible = ACPI_PLD_GET_USER_VISIBLE (&Dword);
588 PldInfo->Dock = ACPI_PLD_GET_DOCK (&Dword);
589 PldInfo->Lid = ACPI_PLD_GET_LID (&Dword);
590 PldInfo->Panel = ACPI_PLD_GET_PANEL (&Dword);
591 PldInfo->VerticalPosition = ACPI_PLD_GET_VERTICAL (&Dword);
592 PldInfo->HorizontalPosition = ACPI_PLD_GET_HORIZONTAL (&Dword);
593 PldInfo->Shape = ACPI_PLD_GET_SHAPE (&Dword);
594 PldInfo->GroupOrientation = ACPI_PLD_GET_ORIENTATION (&Dword);
595 PldInfo->GroupToken = ACPI_PLD_GET_TOKEN (&Dword);
596 PldInfo->GroupPosition = ACPI_PLD_GET_POSITION (&Dword);
597 PldInfo->Bay = ACPI_PLD_GET_BAY (&Dword);
598
599 /* Fourth 32-bit DWord */
600
601 ACPI_MOVE_32_TO_32 (&Dword, &Buffer[3]);
602 PldInfo->Ejectable = ACPI_PLD_GET_EJECTABLE (&Dword);
603 PldInfo->OspmEjectRequired = ACPI_PLD_GET_OSPM_EJECT (&Dword);
604 PldInfo->CabinetNumber = ACPI_PLD_GET_CABINET (&Dword);
605 PldInfo->CardCageNumber = ACPI_PLD_GET_CARD_CAGE (&Dword);
606 PldInfo->Reference = ACPI_PLD_GET_REFERENCE (&Dword);
607 PldInfo->Rotation = ACPI_PLD_GET_ROTATION (&Dword);
608 PldInfo->Order = ACPI_PLD_GET_ORDER (&Dword);
609
610 if (Length >= ACPI_PLD_BUFFER_SIZE)
611 {
612 /* Fifth 32-bit DWord (Revision 2 of _PLD) */
613
614 ACPI_MOVE_32_TO_32 (&Dword, &Buffer[4]);
615 PldInfo->VerticalOffset = ACPI_PLD_GET_VERT_OFFSET (&Dword);
616 PldInfo->HorizontalOffset = ACPI_PLD_GET_HORIZ_OFFSET (&Dword);
617 }
618
619 *ReturnBuffer = PldInfo;
620 return (AE_OK);
621}
622
623ACPI_EXPORT_SYMBOL (AcpiDecodePldBuffer)