1 /******************************************************************************
3 * Module Name: cminit - Common ACPI subsystem initialization
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 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
29 #define _COMPONENT ACPI_UTILITIES
30 MODULE_NAME ("cminit")
33 #define ACPI_OFFSET(d,o) ((u32) &(((d *)0)->o))
34 #define ACPI_FADT_OFFSET(o) ACPI_OFFSET (FADT_DESCRIPTOR, o)
36 /*******************************************************************************
38 * FUNCTION: Acpi_cm_fadt_register_error
40 * PARAMETERS: *Register_name - Pointer to string identifying register
41 * Value - Actual register contents value
42 * Acpi_test_spec_section - TDS section containing assertion
43 * Acpi_assertion - Assertion number being tested
45 * RETURN: AE_BAD_VALUE
47 * DESCRIPTION: Display failure message and link failure to TDS assertion
49 ******************************************************************************/
52 acpi_cm_fadt_register_error (
53 NATIVE_CHAR
*register_name
,
59 ("Invalid FADT value %s=%lX at offset %lX FADT=%p\n",
60 register_name
, value
, offset
, acpi_gbl_FADT
));
63 return (AE_BAD_VALUE
);
67 /******************************************************************************
69 * FUNCTION: Acpi_cm_validate_fadt
75 * DESCRIPTION: Validate various ACPI registers in the FADT
77 ******************************************************************************/
80 acpi_cm_validate_fadt (
83 ACPI_STATUS status
= AE_OK
;
87 * Verify Fixed ACPI Description Table fields,
88 * but don't abort on any problems, just display error
91 if (acpi_gbl_FADT
->pm1_evt_len
< 4) {
92 status
= acpi_cm_fadt_register_error ("PM1_EVT_LEN",
93 (u32
) acpi_gbl_FADT
->pm1_evt_len
,
94 ACPI_FADT_OFFSET (pm1_evt_len
));
97 if (!acpi_gbl_FADT
->pm1_cnt_len
) {
98 status
= acpi_cm_fadt_register_error ("PM1_CNT_LEN", 0,
99 ACPI_FADT_OFFSET (pm1_cnt_len
));
102 if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT
->Xpm1a_evt_blk
.address
)) {
103 status
= acpi_cm_fadt_register_error ("X_PM1a_EVT_BLK", 0,
104 ACPI_FADT_OFFSET (Xpm1a_evt_blk
.address
));
107 if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT
->Xpm1a_cnt_blk
.address
)) {
108 status
= acpi_cm_fadt_register_error ("X_PM1a_CNT_BLK", 0,
109 ACPI_FADT_OFFSET (Xpm1a_cnt_blk
.address
));
112 if (!ACPI_VALID_ADDRESS (acpi_gbl_FADT
->Xpm_tmr_blk
.address
)) {
113 status
= acpi_cm_fadt_register_error ("X_PM_TMR_BLK", 0,
114 ACPI_FADT_OFFSET (Xpm_tmr_blk
.address
));
117 if ((ACPI_VALID_ADDRESS (acpi_gbl_FADT
->Xpm2_cnt_blk
.address
) &&
118 !acpi_gbl_FADT
->pm2_cnt_len
)) {
119 status
= acpi_cm_fadt_register_error ("PM2_CNT_LEN",
120 (u32
) acpi_gbl_FADT
->pm2_cnt_len
,
121 ACPI_FADT_OFFSET (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
,
127 ACPI_FADT_OFFSET (pm_tm_len
));
130 /* length of GPE blocks must be a multiple of 2 */
133 if (ACPI_VALID_ADDRESS (acpi_gbl_FADT
->Xgpe0blk
.address
) &&
134 (acpi_gbl_FADT
->gpe0blk_len
& 1)) {
135 status
= acpi_cm_fadt_register_error ("(x)GPE0_BLK_LEN",
136 (u32
) acpi_gbl_FADT
->gpe0blk_len
,
137 ACPI_FADT_OFFSET (gpe0blk_len
));
140 if (ACPI_VALID_ADDRESS (acpi_gbl_FADT
->Xgpe1_blk
.address
) &&
141 (acpi_gbl_FADT
->gpe1_blk_len
& 1)) {
142 status
= acpi_cm_fadt_register_error ("(x)GPE1_BLK_LEN",
143 (u32
) acpi_gbl_FADT
->gpe1_blk_len
,
144 ACPI_FADT_OFFSET (gpe1_blk_len
));
151 /******************************************************************************
153 * FUNCTION: Acpi_cm_terminate
159 * DESCRIPTION: free memory allocated for table storage.
161 ******************************************************************************/
164 acpi_cm_terminate (void)
168 /* Free global tables, etc. */
170 if (acpi_gbl_gpe0enable_register_save
) {
171 acpi_cm_free (acpi_gbl_gpe0enable_register_save
);
174 if (acpi_gbl_gpe1_enable_register_save
) {
175 acpi_cm_free (acpi_gbl_gpe1_enable_register_save
);
183 /******************************************************************************
185 * FUNCTION: Acpi_cm_subsystem_shutdown
191 * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex
192 * objects here -- because the AML debugger may be still running.
194 ******************************************************************************/
197 acpi_cm_subsystem_shutdown (void)
200 /* Just exit if subsystem is already shutdown */
202 if (acpi_gbl_shutdown
) {
206 /* Subsystem appears active, go ahead and shut it down */
208 acpi_gbl_shutdown
= TRUE
;
210 /* Close the Namespace */
212 acpi_ns_terminate ();
214 /* Close the Acpi_event Handling */
216 acpi_ev_terminate ();
218 /* Close the globals */
220 acpi_cm_terminate ();
222 /* Flush the local cache(s) */
224 acpi_cm_delete_generic_state_cache ();
225 acpi_cm_delete_object_cache ();
226 acpi_ds_delete_walk_state_cache ();
228 /* Close the Parser */
230 /* TBD: [Restructure] Acpi_ps_terminate () */
232 acpi_ps_delete_parse_cache ();
234 /* Debug only - display leftover memory allocation, if any */
235 #ifdef ENABLE_DEBUGGER
236 acpi_cm_dump_current_allocations (ACPI_UINT32_MAX
, NULL
);