Blame view

drivers/acpi/acpica/utxface.c 15.1 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
  /******************************************************************************
   *
   * Module Name: utxface - External interfaces for "global" ACPI functions
   *
   *****************************************************************************/
  
  /*
75a44ce00   Len Brown   ACPICA: update In...
8
   * Copyright (C) 2000 - 2008, Intel Corp.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions, and the following disclaimer,
   *    without modification.
   * 2. Redistributions in binary form must reproduce at minimum a disclaimer
   *    substantially similar to the "NO WARRANTY" disclaimer below
   *    ("Disclaimer") and any redistribution must be conditioned upon
   *    including a substantially similar Disclaimer requirement for further
   *    binary redistribution.
   * 3. Neither the names of the above-listed copyright holders nor the names
   *    of any contributors may be used to endorse or promote products derived
   *    from this software without specific prior written permission.
   *
   * Alternatively, this software may be distributed under the terms of the
   * GNU General Public License ("GPL") version 2 as published by the Free
   * Software Foundation.
   *
   * NO WARRANTY
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
   * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   * POSSIBILITY OF SUCH DAMAGES.
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
  #include <acpi/acpi.h>
e2f7a7772   Len Brown   ACPICA: hide priv...
44
45
46
47
48
  #include "accommon.h"
  #include "acevents.h"
  #include "acnamesp.h"
  #include "acdebug.h"
  #include "actables.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49
50
  
  #define _COMPONENT          ACPI_UTILITIES
4be44fcd3   Len Brown   [ACPI] Lindent al...
51
  ACPI_MODULE_NAME("utxface")
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
52

e20a679b4   Bob Moore   ACPICA: Support f...
53
  #ifndef ACPI_ASL_COMPILER
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
54
55
56
57
58
59
60
61
62
63
64
65
  /*******************************************************************************
   *
   * FUNCTION:    acpi_initialize_subsystem
   *
   * PARAMETERS:  None
   *
   * RETURN:      Status
   *
   * DESCRIPTION: Initializes all global variables.  This is the first function
   *              called, so any early initialization belongs here.
   *
   ******************************************************************************/
dd272b571   Len Brown   ACPI: add __init ...
66
  acpi_status __init acpi_initialize_subsystem(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
67
  {
4be44fcd3   Len Brown   [ACPI] Lindent al...
68
  	acpi_status status;
44f6c0124   Robert Moore   ACPICA 20050408 f...
69

b229cf92e   Bob Moore   ACPI: ACPICA 2006...
70
  	ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71

cb219bb6b   Bob Moore   ACPICA: Add new s...
72
  	acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
4be44fcd3   Len Brown   [ACPI] Lindent al...
73
  	ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
74

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
75
  	/* Initialize the OS-Dependent layer */
4be44fcd3   Len Brown   [ACPI] Lindent al...
76
77
  	status = acpi_os_initialize();
  	if (ACPI_FAILURE(status)) {
b8e4d8935   Bob Moore   [ACPI] ACPICA 200...
78
  		ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
4be44fcd3   Len Brown   [ACPI] Lindent al...
79
  		return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
80
  	}
73459f73e   Robert Moore   ACPICA 20050617-0...
81
  	/* Initialize all globals used by the subsystem */
b417d40b9   Yi Yang   ACPICA: Return st...
82
83
84
85
86
87
  	status = acpi_ut_init_globals();
  	if (ACPI_FAILURE(status)) {
  		ACPI_EXCEPTION((AE_INFO, status,
  				"During initialization of globals"));
  		return_ACPI_STATUS(status);
  	}
73459f73e   Robert Moore   ACPICA 20050617-0...
88

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
89
  	/* Create the default mutex objects */
4be44fcd3   Len Brown   [ACPI] Lindent al...
90
91
  	status = acpi_ut_mutex_initialize();
  	if (ACPI_FAILURE(status)) {
b8e4d8935   Bob Moore   [ACPI] ACPICA 200...
92
93
  		ACPI_EXCEPTION((AE_INFO, status,
  				"During Global Mutex creation"));
4be44fcd3   Len Brown   [ACPI] Lindent al...
94
  		return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
95
96
97
98
99
100
  	}
  
  	/*
  	 * Initialize the namespace manager and
  	 * the root of the namespace tree
  	 */
4be44fcd3   Len Brown   [ACPI] Lindent al...
101
102
  	status = acpi_ns_root_initialize();
  	if (ACPI_FAILURE(status)) {
b8e4d8935   Bob Moore   [ACPI] ACPICA 200...
103
104
  		ACPI_EXCEPTION((AE_INFO, status,
  				"During Namespace initialization"));
4be44fcd3   Len Brown   [ACPI] Lindent al...
105
  		return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
  	/* If configured, initialize the AML debugger */
4be44fcd3   Len Brown   [ACPI] Lindent al...
108
  	ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
4be44fcd3   Len Brown   [ACPI] Lindent al...
109
  	return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
111
112
113
114
115
116
117
118
119
120
121
122
  /*******************************************************************************
   *
   * FUNCTION:    acpi_enable_subsystem
   *
   * PARAMETERS:  Flags           - Init/enable Options
   *
   * RETURN:      Status
   *
   * DESCRIPTION: Completes the subsystem initialization including hardware.
   *              Puts system into ACPI mode if it isn't already.
   *
   ******************************************************************************/
4be44fcd3   Len Brown   [ACPI] Lindent al...
123
  acpi_status acpi_enable_subsystem(u32 flags)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
  {
4be44fcd3   Len Brown   [ACPI] Lindent al...
125
  	acpi_status status = AE_OK;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
126

b229cf92e   Bob Moore   ACPI: ACPICA 2006...
127
  	ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
128

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
129
130
131
  	/* Enable ACPI mode */
  
  	if (!(flags & ACPI_NO_ACPI_ENABLE)) {
4be44fcd3   Len Brown   [ACPI] Lindent al...
132
133
134
  		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  				  "[Init] Going into ACPI mode
  "));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
135
136
  
  		acpi_gbl_original_mode = acpi_hw_get_mode();
4be44fcd3   Len Brown   [ACPI] Lindent al...
137
138
  		status = acpi_enable();
  		if (ACPI_FAILURE(status)) {
b229cf92e   Bob Moore   ACPI: ACPICA 2006...
139
  			ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
4be44fcd3   Len Brown   [ACPI] Lindent al...
140
  			return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
141
142
143
144
  		}
  	}
  
  	/*
009c4cbe9   Bob Moore   ACPICA: Add globa...
145
146
147
148
149
150
151
152
153
154
  	 * Obtain a permanent mapping for the FACS. This is required for the
  	 * Global Lock and the Firmware Waking Vector
  	 */
  	status = acpi_tb_initialize_facs();
  	if (ACPI_FAILURE(status)) {
  		ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
  		return_ACPI_STATUS(status);
  	}
  
  	/*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
155
156
157
158
159
  	 * Install the default op_region handlers. These are installed unless
  	 * other handlers have already been installed via the
  	 * install_address_space_handler interface.
  	 */
  	if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
4be44fcd3   Len Brown   [ACPI] Lindent al...
160
161
162
  		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  				  "[Init] Installing default address space handlers
  "));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
163

4be44fcd3   Len Brown   [ACPI] Lindent al...
164
165
166
  		status = acpi_ev_install_region_handlers();
  		if (ACPI_FAILURE(status)) {
  			return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
167
168
169
170
171
172
  		}
  	}
  
  	/*
  	 * Initialize ACPI Event handling (Fixed and General Purpose)
  	 *
96db255c8   Bob Moore   [ACPI] ACPICA 200...
173
174
175
176
177
178
179
180
  	 * Note1: We must have the hardware and events initialized before we can
  	 * execute any control methods safely. Any control method can require
  	 * ACPI hardware support, so the hardware must be fully initialized before
  	 * any method execution!
  	 *
  	 * Note2: Fixed events are initialized and enabled here. GPEs are
  	 * initialized, but cannot be enabled until after the hardware is
  	 * completely initialized (SCI and global_lock activated)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
181
182
  	 */
  	if (!(flags & ACPI_NO_EVENT_INIT)) {
4be44fcd3   Len Brown   [ACPI] Lindent al...
183
184
185
  		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  				  "[Init] Initializing ACPI events
  "));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
186

4be44fcd3   Len Brown   [ACPI] Lindent al...
187
188
189
  		status = acpi_ev_initialize_events();
  		if (ACPI_FAILURE(status)) {
  			return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
190
191
  		}
  	}
96db255c8   Bob Moore   [ACPI] ACPICA 200...
192
193
194
195
  	/*
  	 * Install the SCI handler and Global Lock handler. This completes the
  	 * hardware initialization.
  	 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
196
  	if (!(flags & ACPI_NO_HANDLER_INIT)) {
4be44fcd3   Len Brown   [ACPI] Lindent al...
197
198
199
  		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  				  "[Init] Installing SCI/GL handlers
  "));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
200

4be44fcd3   Len Brown   [ACPI] Lindent al...
201
202
203
  		status = acpi_ev_install_xrupt_handlers();
  		if (ACPI_FAILURE(status)) {
  			return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
204
205
  		}
  	}
4be44fcd3   Len Brown   [ACPI] Lindent al...
206
  	return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
207
  }
8313524a0   Bob Moore   ACPI: ACPICA 2006...
208
  ACPI_EXPORT_SYMBOL(acpi_enable_subsystem)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
209
210
211
212
213
214
215
216
217
218
219
220
  /*******************************************************************************
   *
   * FUNCTION:    acpi_initialize_objects
   *
   * PARAMETERS:  Flags           - Init/enable Options
   *
   * RETURN:      Status
   *
   * DESCRIPTION: Completes namespace initialization by initializing device
   *              objects and executing AML code for Regions, buffers, etc.
   *
   ******************************************************************************/
4be44fcd3   Len Brown   [ACPI] Lindent al...
221
  acpi_status acpi_initialize_objects(u32 flags)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
222
  {
4be44fcd3   Len Brown   [ACPI] Lindent al...
223
  	acpi_status status = AE_OK;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
224

b229cf92e   Bob Moore   ACPI: ACPICA 2006...
225
  	ACPI_FUNCTION_TRACE(acpi_initialize_objects);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
226
227
228
229
  
  	/*
  	 * Run all _REG methods
  	 *
96db255c8   Bob Moore   [ACPI] ACPICA 200...
230
231
232
  	 * Note: Any objects accessed by the _REG methods will be automatically
  	 * initialized, even if they contain executable AML (see the call to
  	 * acpi_ns_initialize_objects below).
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
233
234
  	 */
  	if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
4be44fcd3   Len Brown   [ACPI] Lindent al...
235
  		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
b229cf92e   Bob Moore   ACPI: ACPICA 2006...
236
237
  				  "[Init] Executing _REG OpRegion methods
  "));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
238

4be44fcd3   Len Brown   [ACPI] Lindent al...
239
240
241
  		status = acpi_ev_initialize_op_regions();
  		if (ACPI_FAILURE(status)) {
  			return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
242
243
244
245
  		}
  	}
  
  	/*
7f0c826a4   Lin Ming   ACPICA: Add suppo...
246
247
248
249
250
251
252
253
254
255
  	 * Execute any module-level code that was detected during the table load
  	 * phase. Although illegal since ACPI 2.0, there are many machines that
  	 * contain this type of code. Each block of detected executable AML code
  	 * outside of any control method is wrapped with a temporary control
  	 * method object and placed on a global list. The methods on this list
  	 * are executed below.
  	 */
  	acpi_ns_exec_module_code_list();
  
  	/*
96db255c8   Bob Moore   [ACPI] ACPICA 200...
256
257
258
  	 * Initialize the objects that remain uninitialized. This runs the
  	 * executable AML that may be part of the declaration of these objects:
  	 * operation_regions, buffer_fields, Buffers, and Packages.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
259
260
  	 */
  	if (!(flags & ACPI_NO_OBJECT_INIT)) {
4be44fcd3   Len Brown   [ACPI] Lindent al...
261
262
263
  		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  				  "[Init] Completing Initialization of ACPI Objects
  "));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
264

4be44fcd3   Len Brown   [ACPI] Lindent al...
265
266
267
  		status = acpi_ns_initialize_objects();
  		if (ACPI_FAILURE(status)) {
  			return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
268
269
270
271
  		}
  	}
  
  	/*
96db255c8   Bob Moore   [ACPI] ACPICA 200...
272
273
  	 * Initialize all device objects in the namespace. This runs the device
  	 * _STA and _INI methods.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
274
275
  	 */
  	if (!(flags & ACPI_NO_DEVICE_INIT)) {
4be44fcd3   Len Brown   [ACPI] Lindent al...
276
277
278
  		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  				  "[Init] Initializing ACPI Devices
  "));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
279

4be44fcd3   Len Brown   [ACPI] Lindent al...
280
281
282
  		status = acpi_ns_initialize_devices();
  		if (ACPI_FAILURE(status)) {
  			return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
283
284
285
286
  		}
  	}
  
  	/*
204470272   Alexey Starikovskiy   ACPI: GPE enablin...
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
  	 * Complete the GPE initialization for the GPE blocks defined in the FADT
  	 * (GPE block 0 and 1).
  	 *
  	 * Note1: This is where the _PRW methods are executed for the GPEs. These
  	 * methods can only be executed after the SCI and Global Lock handlers are
  	 * installed and initialized.
  	 *
  	 * Note2: Currently, there seems to be no need to run the _REG methods
  	 * before execution of the _PRW methods and enabling of the GPEs.
  	 */
  	if (!(flags & ACPI_NO_EVENT_INIT)) {
  		status = acpi_ev_install_fadt_gpes();
  		if (ACPI_FAILURE(status))
  			return (status);
  	}
  
  	/*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
304
305
306
307
  	 * Empty the caches (delete the cached objects) on the assumption that
  	 * the table load filled them up more than they will be at runtime --
  	 * thus wasting non-paged memory.
  	 */
4be44fcd3   Len Brown   [ACPI] Lindent al...
308
  	status = acpi_purge_cached_objects();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
309
310
  
  	acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
4be44fcd3   Len Brown   [ACPI] Lindent al...
311
  	return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
312
  }
8313524a0   Bob Moore   ACPI: ACPICA 2006...
313
  ACPI_EXPORT_SYMBOL(acpi_initialize_objects)
e20a679b4   Bob Moore   ACPICA: Support f...
314
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
315
316
317
318
319
320
321
322
  /*******************************************************************************
   *
   * FUNCTION:    acpi_terminate
   *
   * PARAMETERS:  None
   *
   * RETURN:      Status
   *
2f977b36e   Bob Moore   ACPICA: Fix fault...
323
   * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
324
325
   *
   ******************************************************************************/
4be44fcd3   Len Brown   [ACPI] Lindent al...
326
  acpi_status acpi_terminate(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
327
  {
4be44fcd3   Len Brown   [ACPI] Lindent al...
328
  	acpi_status status;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
329

b229cf92e   Bob Moore   ACPI: ACPICA 2006...
330
  	ACPI_FUNCTION_TRACE(acpi_terminate);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
331

2f977b36e   Bob Moore   ACPICA: Fix fault...
332
333
334
335
336
337
338
339
340
341
342
343
344
  	/* Just exit if subsystem is already shutdown */
  
  	if (acpi_gbl_shutdown) {
  		ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
  		return_ACPI_STATUS(AE_OK);
  	}
  
  	/* Subsystem appears active, go ahead and shut it down */
  
  	acpi_gbl_shutdown = TRUE;
  	acpi_gbl_startup_flags = 0;
  	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem
  "));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
345
346
347
348
349
  	/* Terminate the AML Debugger if present */
  
  	ACPI_DEBUGGER_EXEC(acpi_gbl_db_terminate_threads = TRUE);
  
  	/* Shutdown and free all resources */
4be44fcd3   Len Brown   [ACPI] Lindent al...
350
  	acpi_ut_subsystem_shutdown();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
351
352
  
  	/* Free the mutex objects */
4be44fcd3   Len Brown   [ACPI] Lindent al...
353
  	acpi_ut_mutex_terminate();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
354
355
356
357
  
  #ifdef ACPI_DEBUGGER
  
  	/* Shut down the debugger */
4be44fcd3   Len Brown   [ACPI] Lindent al...
358
  	acpi_db_terminate();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
359
360
361
  #endif
  
  	/* Now we can shutdown the OS-dependent layer */
4be44fcd3   Len Brown   [ACPI] Lindent al...
362
363
  	status = acpi_os_terminate();
  	return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
364
  }
8313524a0   Bob Moore   ACPI: ACPICA 2006...
365
  ACPI_EXPORT_SYMBOL(acpi_terminate)
2f977b36e   Bob Moore   ACPICA: Fix fault...
366

e20a679b4   Bob Moore   ACPICA: Support f...
367
  #ifndef ACPI_ASL_COMPILER
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
368
  #ifdef ACPI_FUTURE_USAGE
44f6c0124   Robert Moore   ACPICA 20050408 f...
369
  /*******************************************************************************
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
370
371
372
373
374
375
376
377
   *
   * FUNCTION:    acpi_subsystem_status
   *
   * PARAMETERS:  None
   *
   * RETURN:      Status of the ACPI subsystem
   *
   * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
44f6c0124   Robert Moore   ACPICA 20050408 f...
378
379
   *              before making any other calls, to ensure the subsystem
   *              initialized successfully.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
380
   *
44f6c0124   Robert Moore   ACPICA 20050408 f...
381
   ******************************************************************************/
4be44fcd3   Len Brown   [ACPI] Lindent al...
382
  acpi_status acpi_subsystem_status(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
383
  {
44f6c0124   Robert Moore   ACPICA 20050408 f...
384

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
385
386
  	if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) {
  		return (AE_OK);
4be44fcd3   Len Brown   [ACPI] Lindent al...
387
  	} else {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
388
389
390
  		return (AE_ERROR);
  	}
  }
8313524a0   Bob Moore   ACPI: ACPICA 2006...
391
  ACPI_EXPORT_SYMBOL(acpi_subsystem_status)
44f6c0124   Robert Moore   ACPICA 20050408 f...
392
  /*******************************************************************************
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
393
394
395
   *
   * FUNCTION:    acpi_get_system_info
   *
44f6c0124   Robert Moore   ACPICA 20050408 f...
396
397
   * PARAMETERS:  out_buffer      - A buffer to receive the resources for the
   *                                device
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
398
399
400
401
402
403
404
405
406
407
408
   *
   * RETURN:      Status          - the status of the call
   *
   * DESCRIPTION: This function is called to get information about the current
   *              state of the ACPI subsystem.  It will return system information
   *              in the out_buffer.
   *
   *              If the function fails an appropriate status will be returned
   *              and the value of out_buffer is undefined.
   *
   ******************************************************************************/
4be44fcd3   Len Brown   [ACPI] Lindent al...
409
  acpi_status acpi_get_system_info(struct acpi_buffer * out_buffer)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
410
  {
4be44fcd3   Len Brown   [ACPI] Lindent al...
411
412
  	struct acpi_system_info *info_ptr;
  	acpi_status status;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
413

b229cf92e   Bob Moore   ACPI: ACPICA 2006...
414
  	ACPI_FUNCTION_TRACE(acpi_get_system_info);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
415
416
  
  	/* Parameter validation */
4be44fcd3   Len Brown   [ACPI] Lindent al...
417
418
419
  	status = acpi_ut_validate_buffer(out_buffer);
  	if (ACPI_FAILURE(status)) {
  		return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
420
421
422
  	}
  
  	/* Validate/Allocate/Clear caller buffer */
4be44fcd3   Len Brown   [ACPI] Lindent al...
423
424
425
426
427
  	status =
  	    acpi_ut_initialize_buffer(out_buffer,
  				      sizeof(struct acpi_system_info));
  	if (ACPI_FAILURE(status)) {
  		return_ACPI_STATUS(status);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
428
429
430
431
432
  	}
  
  	/*
  	 * Populate the return buffer
  	 */
4be44fcd3   Len Brown   [ACPI] Lindent al...
433
  	info_ptr = (struct acpi_system_info *)out_buffer->pointer;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
434

4be44fcd3   Len Brown   [ACPI] Lindent al...
435
  	info_ptr->acpi_ca_version = ACPI_CA_VERSION;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
436
437
  
  	/* System flags (ACPI capabilities) */
4be44fcd3   Len Brown   [ACPI] Lindent al...
438
  	info_ptr->flags = ACPI_SYS_MODE_ACPI;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
439
440
  
  	/* Timer resolution - 24 or 32 bits  */
f3d2e7865   Bob Moore   ACPICA: Implement...
441
  	if (acpi_gbl_FADT.flags & ACPI_FADT_32BIT_TIMER) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
442
  		info_ptr->timer_resolution = 24;
4be44fcd3   Len Brown   [ACPI] Lindent al...
443
  	} else {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
444
445
446
447
  		info_ptr->timer_resolution = 32;
  	}
  
  	/* Clear the reserved fields */
4be44fcd3   Len Brown   [ACPI] Lindent al...
448
449
  	info_ptr->reserved1 = 0;
  	info_ptr->reserved2 = 0;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
450
451
  
  	/* Current debug levels */
4be44fcd3   Len Brown   [ACPI] Lindent al...
452
453
  	info_ptr->debug_layer = acpi_dbg_layer;
  	info_ptr->debug_level = acpi_dbg_level;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
454

4be44fcd3   Len Brown   [ACPI] Lindent al...
455
  	return_ACPI_STATUS(AE_OK);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
456
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
457

8313524a0   Bob Moore   ACPI: ACPICA 2006...
458
  ACPI_EXPORT_SYMBOL(acpi_get_system_info)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
459
460
461
462
463
464
  
  /*****************************************************************************
   *
   * FUNCTION:    acpi_install_initialization_handler
   *
   * PARAMETERS:  Handler             - Callback procedure
44f6c0124   Robert Moore   ACPICA 20050408 f...
465
   *              Function            - Not (currently) used, see below
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
466
467
468
469
470
471
472
473
   *
   * RETURN:      Status
   *
   * DESCRIPTION: Install an initialization handler
   *
   * TBD: When a second function is added, must save the Function also.
   *
   ****************************************************************************/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
474
  acpi_status
4be44fcd3   Len Brown   [ACPI] Lindent al...
475
  acpi_install_initialization_handler(acpi_init_handler handler, u32 function)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
476
477
478
479
480
481
482
483
484
485
486
487
488
  {
  
  	if (!handler) {
  		return (AE_BAD_PARAMETER);
  	}
  
  	if (acpi_gbl_init_handler) {
  		return (AE_ALREADY_EXISTS);
  	}
  
  	acpi_gbl_init_handler = handler;
  	return AE_OK;
  }
8313524a0   Bob Moore   ACPI: ACPICA 2006...
489
  ACPI_EXPORT_SYMBOL(acpi_install_initialization_handler)
4be44fcd3   Len Brown   [ACPI] Lindent al...
490
  #endif				/*  ACPI_FUTURE_USAGE  */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
491
492
493
494
495
496
497
498
499
500
501
  /*****************************************************************************
   *
   * FUNCTION:    acpi_purge_cached_objects
   *
   * PARAMETERS:  None
   *
   * RETURN:      Status
   *
   * DESCRIPTION: Empty all caches (delete the cached objects)
   *
   ****************************************************************************/
4be44fcd3   Len Brown   [ACPI] Lindent al...
502
  acpi_status acpi_purge_cached_objects(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
503
  {
b229cf92e   Bob Moore   ACPI: ACPICA 2006...
504
  	ACPI_FUNCTION_TRACE(acpi_purge_cached_objects);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
505

4be44fcd3   Len Brown   [ACPI] Lindent al...
506
507
508
509
510
  	(void)acpi_os_purge_cache(acpi_gbl_state_cache);
  	(void)acpi_os_purge_cache(acpi_gbl_operand_cache);
  	(void)acpi_os_purge_cache(acpi_gbl_ps_node_cache);
  	(void)acpi_os_purge_cache(acpi_gbl_ps_node_ext_cache);
  	return_ACPI_STATUS(AE_OK);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
511
  }
8313524a0   Bob Moore   ACPI: ACPICA 2006...
512
513
  
  ACPI_EXPORT_SYMBOL(acpi_purge_cached_objects)
e20a679b4   Bob Moore   ACPICA: Support f...
514
  #endif