- Kai Germaschewski: ISDN update (including Makefiles)
[davej-history.git] / drivers / acpi / common / cminit.c
blobbabf941d2f779e9640153f1365329c3d0115d881
1 /******************************************************************************
3 * Module Name: cminit - Common ACPI subsystem initialization
4 * $Revision: 89 $
6 *****************************************************************************/
8 /*
9 * Copyright (C) 2000 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "acpi.h"
28 #include "achware.h"
29 #include "acnamesp.h"
30 #include "acevents.h"
31 #include "acparser.h"
32 #include "acdispat.h"
34 #define _COMPONENT MISCELLANEOUS
35 MODULE_NAME ("cminit")
38 /*******************************************************************************
40 * FUNCTION: Acpi_cm_fadt_register_error
42 * PARAMETERS: *Register_name - Pointer to string identifying register
43 * Value - Actual register contents value
44 * Acpi_test_spec_section - TDS section containing assertion
45 * Acpi_assertion - Assertion number being tested
47 * RETURN: AE_BAD_VALUE
49 * DESCRIPTION: Display failure message and link failure to TDS assertion
51 ******************************************************************************/
53 static ACPI_STATUS
54 acpi_cm_fadt_register_error (
55 NATIVE_CHAR *register_name,
56 UINT64 value)
59 REPORT_ERROR (
60 ("Invalid FADT register value, %s=%X (FADT=%p)\n",
61 register_name, value, acpi_gbl_FADT));
64 return (AE_BAD_VALUE);
68 /******************************************************************************
70 * FUNCTION: Acpi_cm_validate_fadt
72 * PARAMETERS: None
74 * RETURN: Status
76 * DESCRIPTION: Validate various ACPI registers in the FADT
78 ******************************************************************************/
80 ACPI_STATUS
81 acpi_cm_validate_fadt (
82 void)
84 ACPI_STATUS status = AE_OK;
88 * Verify Fixed ACPI Description Table fields,
89 * but don't abort on any problems, just display error
92 if (acpi_gbl_FADT->pm1_evt_len < 4) {
93 status = acpi_cm_fadt_register_error ("PM1_EVT_LEN",
94 (u32) acpi_gbl_FADT->pm1_evt_len);
97 if (!acpi_gbl_FADT->pm1_cnt_len) {
98 status = acpi_cm_fadt_register_error ("PM1_CNT_LEN",
99 (u32) acpi_gbl_FADT->pm1_cnt_len);
102 if (!acpi_gbl_FADT->Xpm1a_evt_blk.address) {
103 status = acpi_cm_fadt_register_error ("PM1a_EVT_BLK",
104 acpi_gbl_FADT->Xpm1a_evt_blk.address);
107 if (!acpi_gbl_FADT->Xpm1a_cnt_blk.address) {
108 status = acpi_cm_fadt_register_error ("PM1a_CNT_BLK",
109 acpi_gbl_FADT->Xpm1a_cnt_blk.address);
112 if (!acpi_gbl_FADT->Xpm_tmr_blk.address) {
113 status = acpi_cm_fadt_register_error ("PM_TMR_BLK",
114 acpi_gbl_FADT->Xpm_tmr_blk.address);
117 if ((acpi_gbl_FADT->Xpm2_cnt_blk.address &&
118 !acpi_gbl_FADT->pm2_cnt_len))
120 status = acpi_cm_fadt_register_error ("PM2_CNT_LEN",
121 (u32) acpi_gbl_FADT->pm2_cnt_len);
124 if (acpi_gbl_FADT->pm_tm_len < 4) {
125 status = acpi_cm_fadt_register_error ("PM_TM_LEN",
126 (u32) acpi_gbl_FADT->pm_tm_len);
129 /* length of GPE blocks must be a multiple of 2 */
132 if (acpi_gbl_FADT->Xgpe0blk.address &&
133 (acpi_gbl_FADT->gpe0blk_len & 1))
135 status = acpi_cm_fadt_register_error ("GPE0_BLK_LEN",
136 (u32) acpi_gbl_FADT->gpe0blk_len);
139 if (acpi_gbl_FADT->Xgpe1_blk.address &&
140 (acpi_gbl_FADT->gpe1_blk_len & 1))
142 status = acpi_cm_fadt_register_error ("GPE1_BLK_LEN",
143 (u32) acpi_gbl_FADT->gpe1_blk_len);
146 return (status);
150 /******************************************************************************
152 * FUNCTION: Acpi_cm_terminate
154 * PARAMETERS: none
156 * RETURN: none
158 * DESCRIPTION: free memory allocated for table storage.
160 ******************************************************************************/
162 void
163 acpi_cm_terminate (void)
167 /* Free global tables, etc. */
169 if (acpi_gbl_gpe0enable_register_save) {
170 acpi_cm_free (acpi_gbl_gpe0enable_register_save);
173 if (acpi_gbl_gpe1_enable_register_save) {
174 acpi_cm_free (acpi_gbl_gpe1_enable_register_save);
178 return;
182 /******************************************************************************
184 * FUNCTION: Acpi_cm_subsystem_shutdown
186 * PARAMETERS: none
188 * RETURN: none
190 * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex
191 * objects here -- because the AML debugger may be still running.
193 ******************************************************************************/
195 ACPI_STATUS
196 acpi_cm_subsystem_shutdown (void)
199 /* Just exit if subsystem is already shutdown */
201 if (acpi_gbl_shutdown) {
202 return (AE_OK);
205 /* Subsystem appears active, go ahead and shut it down */
207 acpi_gbl_shutdown = TRUE;
209 /* Close the Namespace */
211 acpi_ns_terminate ();
213 /* Close the Acpi_event Handling */
215 acpi_ev_terminate ();
217 /* Close the globals */
219 acpi_cm_terminate ();
221 /* Flush the local cache(s) */
223 acpi_cm_delete_generic_state_cache ();
224 acpi_cm_delete_object_cache ();
225 acpi_ds_delete_walk_state_cache ();
227 /* Close the Parser */
229 /* TBD: [Restructure] Acpi_ps_terminate () */
231 acpi_ps_delete_parse_cache ();
233 /* Debug only - display leftover memory allocation, if any */
234 #ifdef ENABLE_DEBUGGER
235 acpi_cm_dump_current_allocations (ACPI_UINT32_MAX, NULL);
236 #endif
238 return (AE_OK);