1 /******************************************************************************
3 * Module Name: tbxfroot - Find the root ACPI table (RSDT)
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
32 #define _COMPONENT ACPI_TABLES
33 MODULE_NAME ("tbxfroot")
35 #define RSDP_CHECKSUM_LENGTH 20
38 /*******************************************************************************
40 * FUNCTION: Acpi_find_root_pointer
42 * PARAMETERS: **Rsdp_physical_address - Where to place the RSDP address
44 * RETURN: Status, Physical address of the RSDP
46 * DESCRIPTION: Find the RSDP
48 ******************************************************************************/
51 acpi_find_root_pointer (
52 ACPI_PHYSICAL_ADDRESS *rsdp_physical_address)
54 ACPI_TABLE_DESC table_info;
60 status = acpi_tb_find_rsdp (&table_info);
61 if (ACPI_FAILURE (status)) {
62 return (AE_NO_ACPI_TABLES);
65 *rsdp_physical_address = table_info.physical_address;
71 /*******************************************************************************
73 * FUNCTION: Acpi_tb_scan_memory_for_rsdp
75 * PARAMETERS: Start_address - Starting pointer for search
76 * Length - Maximum length to search
78 * RETURN: Pointer to the RSDP if found, otherwise NULL.
80 * DESCRIPTION: Search a block of memory for the RSDP signature
82 ******************************************************************************/
85 acpi_tb_scan_memory_for_rsdp (
93 /* Search from given start addr for the requested length */
95 for (offset = 0, mem_rover = start_address;
97 offset += RSDP_SCAN_STEP, mem_rover += RSDP_SCAN_STEP) {
99 /* The signature and checksum must both be correct */
101 if (STRNCMP ((NATIVE_CHAR *) mem_rover,
102 RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 &&
103 acpi_tb_checksum (mem_rover, RSDP_CHECKSUM_LENGTH) == 0) {
104 /* If so, we have found the RSDP */
110 /* Searched entire block, no RSDP was found */
116 /*******************************************************************************
118 * FUNCTION: Acpi_tb_find_rsdp
120 * PARAMETERS: *Buffer_ptr - If == NULL, read data from buffer
121 * rather than searching memory
122 * *Table_info - Where the table info is returned
126 * DESCRIPTION: Search lower 1_mbyte of memory for the root system descriptor
127 * pointer structure. If it is found, set *RSDP to point to it.
129 * NOTE: The RSDP must be either in the first 1_k of the Extended
130 * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section
131 * 5.2.2; assertion #421).
133 ******************************************************************************/
137 ACPI_TABLE_DESC *table_info)
142 ACPI_STATUS status = AE_OK;
146 * Search memory for RSDP. First map low physical memory.
149 status = acpi_os_map_memory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE,
150 (void **)&table_ptr);
152 if (ACPI_FAILURE (status)) {
157 * 1) Search EBDA (low memory) paragraphs
160 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, LO_RSDP_WINDOW_SIZE);
162 /* This mapping is no longer needed */
164 acpi_os_unmap_memory (table_ptr, LO_RSDP_WINDOW_SIZE);
167 /* Found it, return the physical address */
169 phys_addr = LO_RSDP_WINDOW_BASE;
170 phys_addr += (mem_rover - table_ptr);
172 table_info->physical_address = phys_addr;
179 * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
182 status = acpi_os_map_memory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE,
183 (void **)&table_ptr);
185 if (ACPI_FAILURE (status)) {
189 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, HI_RSDP_WINDOW_SIZE);
191 /* This mapping is no longer needed */
193 acpi_os_unmap_memory (table_ptr, HI_RSDP_WINDOW_SIZE);
196 /* Found it, return the physical address */
198 phys_addr = HI_RSDP_WINDOW_BASE;
199 phys_addr += (mem_rover - table_ptr);
201 table_info->physical_address = phys_addr;
207 /* RSDP signature was not found */
209 return (AE_NOT_FOUND);