- Kai Germaschewski: ISDN update (including Makefiles)
[davej-history.git] / drivers / acpi / tables / tbxfroot.c
blob4c31f1c37c65e06db27c80dbae53c79b43ca8388
1 /******************************************************************************
3 * Module Name: tbxfroot - Find the root ACPI table (RSDT)
4 * $Revision: 33 $
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 "actables.h"
32 #define _COMPONENT TABLE_MANAGER
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 ******************************************************************************/
50 ACPI_STATUS
51 acpi_find_root_pointer (
52 ACPI_PHYSICAL_ADDRESS *rsdp_physical_address)
54 ACPI_TABLE_DESC table_info;
55 ACPI_STATUS status;
58 /* Get the RSDP */
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;
67 return (AE_OK);
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 ******************************************************************************/
84 u8 *
85 acpi_tb_scan_memory_for_rsdp (
86 u8 *start_address,
87 u32 length)
89 u32 offset;
90 u8 *mem_rover;
93 /* Search from given start addr for the requested length */
95 for (offset = 0, mem_rover = start_address;
96 offset < length;
97 offset += RSDP_SCAN_STEP, mem_rover += RSDP_SCAN_STEP)
100 /* The signature and checksum must both be correct */
102 if (STRNCMP ((NATIVE_CHAR *) mem_rover,
103 RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 &&
104 acpi_tb_checksum (mem_rover, RSDP_CHECKSUM_LENGTH) == 0)
106 /* If so, we have found the RSDP */
108 return (mem_rover);
112 /* Searched entire block, no RSDP was found */
114 return (NULL);
118 /*******************************************************************************
120 * FUNCTION: Acpi_tb_find_rsdp
122 * PARAMETERS: *Buffer_ptr - If == NULL, read data from buffer
123 * rather than searching memory
124 * *Table_info - Where the table info is returned
126 * RETURN: Status
128 * DESCRIPTION: Search lower 1_mbyte of memory for the root system descriptor
129 * pointer structure. If it is found, set *RSDP to point to it.
131 * NOTE: The RSDP must be either in the first 1_k of the Extended
132 * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section
133 * 5.2.2; assertion #421).
135 ******************************************************************************/
137 ACPI_STATUS
138 acpi_tb_find_rsdp (
139 ACPI_TABLE_DESC *table_info)
141 u8 *table_ptr;
142 u8 *mem_rover;
143 UINT64 phys_addr;
144 ACPI_STATUS status = AE_OK;
148 * Search memory for RSDP. First map low physical memory.
151 status = acpi_os_map_memory (LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE,
152 (void **)&table_ptr);
154 if (ACPI_FAILURE (status)) {
155 return (status);
159 * 1) Search EBDA (low memory) paragraphs
162 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, LO_RSDP_WINDOW_SIZE);
164 /* This mapping is no longer needed */
166 acpi_os_unmap_memory (table_ptr, LO_RSDP_WINDOW_SIZE);
168 if (mem_rover) {
169 /* Found it, return the physical address */
171 phys_addr = LO_RSDP_WINDOW_BASE;
172 phys_addr += (mem_rover - table_ptr);
174 table_info->physical_address = phys_addr;
176 return (AE_OK);
181 * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h
184 status = acpi_os_map_memory (HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE,
185 (void **)&table_ptr);
187 if (ACPI_FAILURE (status)) {
188 return (status);
191 mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, HI_RSDP_WINDOW_SIZE);
193 /* This mapping is no longer needed */
195 acpi_os_unmap_memory (table_ptr, HI_RSDP_WINDOW_SIZE);
197 if (mem_rover) {
198 /* Found it, return the physical address */
200 phys_addr = HI_RSDP_WINDOW_BASE;
201 phys_addr += (mem_rover - table_ptr);
203 table_info->physical_address = phys_addr;
205 return (AE_OK);
209 /* RSDP signature was not found */
211 return (AE_NOT_FOUND);