1
2
3
4
5
6
7
8
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
/******************************************************************************
*
* Module Name: cmxface - External interfaces for "global" ACPI functions
* $Revision: 43 $
*
*****************************************************************************/
/*
* Copyright (C) 2000 R. Byron Moore
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "acpi.h"
#include "acevents.h"
#include "achware.h"
#include "acnamesp.h"
#include "acinterp.h"
#include "amlcode.h"
#include "acdebug.h"
#define _COMPONENT MISCELLANEOUS
MODULE_NAME ("cmxface")
/*******************************************************************************
*
* FUNCTION: Acpi_initialize
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Initializes all global variables. This is the first function
* called, so any early initialization belongs here.
*
******************************************************************************/
ACPI_STATUS
acpi_initialize (ACPI_INIT_DATA *init_data)
{
ACPI_STATUS status;
/* Initialize all globals used by the subsystem */
acpi_cm_init_globals (init_data);
/* Initialize the OS-Dependent layer */
status = acpi_os_initialize ();
if (ACPI_FAILURE (status)) {
REPORT_ERROR ("OSD Initialization Failure");
return (status);
}
/* Create the default mutex objects */
status = acpi_cm_mutex_initialize ();
if (ACPI_FAILURE (status)) {
REPORT_ERROR ("Global Mutex Initialization Failure");
return (status);
}
/* If configured, initialize the AML debugger */
DEBUGGER_EXEC (acpi_db_initialize ());
return (status);
}
/*******************************************************************************
*
* FUNCTION: Acpi_terminate
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Shutdown the ACPI subsystem. Release all resources.
*
******************************************************************************/
ACPI_STATUS
acpi_terminate (void)
{
/* Terminate the AML Debuger if present */
acpi_gbl_db_terminate_threads = TRUE;
/* TBD: [Investigate] This is no longer needed?*/
/* Acpi_cm_release_mutex (ACPI_MTX_DEBUG_CMD_READY); */
/* Shutdown and free all resources */
acpi_cm_subsystem_shutdown ();
/* Free the mutex objects */
acpi_cm_mutex_terminate ();
/* Now we can shutdown the OS-dependent layer */
acpi_os_terminate ();
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: Acpi_get_system_info
*
* PARAMETERS: Out_buffer - a pointer to a buffer to receive the
* resources for the device
* Buffer_length - the number of bytes available in the buffer
*
* 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.
*
******************************************************************************/
ACPI_STATUS
acpi_get_system_info (
ACPI_BUFFER *out_buffer)
{
ACPI_SYSTEM_INFO *info_ptr;
u32 i;
/*
* Must have a valid buffer
*/
if ((!out_buffer) ||
(!out_buffer->pointer))
{
return (AE_BAD_PARAMETER);
}
if (out_buffer->length < sizeof (ACPI_SYSTEM_INFO)) {
/*
* Caller's buffer is too small
*/
out_buffer->length = sizeof (ACPI_SYSTEM_INFO);
return (AE_BUFFER_OVERFLOW);
}
/*
* Set return length and get data
*/
out_buffer->length = sizeof (ACPI_SYSTEM_INFO);
info_ptr = (ACPI_SYSTEM_INFO *) out_buffer->pointer;
/* TBD [Future]: need a version number, or use the version string */
info_ptr->acpi_ca_version = 0x1234;
/* System flags (ACPI capabilities) */
info_ptr->flags = acpi_gbl_system_flags;
/* Timer resolution - 24 or 32 bits */
info_ptr->timer_resolution = acpi_hw_pmt_resolution ();
/* Clear the reserved fields */
info_ptr->reserved1 = 0;
info_ptr->reserved2 = 0;
/* Current debug levels */
info_ptr->debug_layer = acpi_dbg_layer;
info_ptr->debug_level = acpi_dbg_level;
/* Current status of the ACPI tables, per table type */
info_ptr->num_table_types = NUM_ACPI_TABLES;
for (i = 0; i < NUM_ACPI_TABLES; i++); {
info_ptr->table_info[i].count = acpi_gbl_acpi_tables[i].count;
}
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: Acpi_format_exception
*
* PARAMETERS: Out_buffer - a pointer to a buffer to receive the
* exception name
*
* RETURN: Status - the status of the call
*
* DESCRIPTION: This function translates an ACPI exception into an ASCII string.
*
******************************************************************************/
ACPI_STATUS
acpi_format_exception (
ACPI_STATUS exception,
ACPI_BUFFER *out_buffer)
{
u32 length;
NATIVE_CHAR *formatted_exception;
/*
* Must have a valid buffer
*/
if ((!out_buffer) ||
(!out_buffer->pointer))
{
return (AE_BAD_PARAMETER);
}
/* Convert the exception code (Handles bad exception codes) */
formatted_exception = acpi_cm_format_exception (exception);
/*
* Get length of string and check if it will fit in caller's buffer
*/
length = STRLEN (formatted_exception);
if (out_buffer->length < length) {
out_buffer->length = length;
return (AE_BUFFER_OVERFLOW);
}
/* Copy the string, all done */
STRCPY (out_buffer->pointer, formatted_exception);
return (AE_OK);
}
|