ia64/xen-unstable

view xen/drivers/acpi/osl.c @ 17840:4ebd8f377426

[IA64] re-add efi support to acpi_os_get_root_pointer()

On ia64 RSDP address is obtained from efi table instead of
memory scan. Otherwise it may use wrong table to fail to find
tables.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 12 15:44:21 2008 +0100 (2008-06-12)
parents 9af7a535225f
children
line source
1 /*
2 * acpi_osl.c - OS-dependent functions ($Revision: 83 $)
3 *
4 * Copyright (C) 2000 Andrew Henroid
5 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
6 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
7 *
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 *
26 */
27 #include <asm/io.h>
28 #include <xen/config.h>
29 #include <xen/init.h>
30 #include <xen/types.h>
31 #include <xen/errno.h>
32 #include <xen/acpi.h>
33 #include <xen/numa.h>
34 #include <acpi/acpi_bus.h>
35 #include <acpi/acmacros.h>
36 #include <acpi/acpiosxf.h>
37 #include <acpi/platform/aclinux.h>
38 #include <xen/spinlock.h>
39 #include <xen/domain_page.h>
40 #ifdef __ia64__
41 #include <linux/efi.h>
42 #endif
44 #define _COMPONENT ACPI_OS_SERVICES
45 ACPI_MODULE_NAME("osl")
46 #define PREFIX "ACPI: "
47 struct acpi_os_dpc {
48 acpi_osd_exec_callback function;
49 void *context;
50 };
52 #ifdef CONFIG_ACPI_CUSTOM_DSDT
53 #include CONFIG_ACPI_CUSTOM_DSDT_FILE
54 #endif
56 #ifdef ENABLE_DEBUGGER
57 #include <linux/kdb.h>
59 /* stuff for debugger support */
60 int acpi_in_debugger;
61 EXPORT_SYMBOL(acpi_in_debugger);
63 extern char line_buf[80];
64 #endif /*ENABLE_DEBUGGER */
66 int acpi_specific_hotkey_enabled = TRUE;
67 EXPORT_SYMBOL(acpi_specific_hotkey_enabled);
69 void acpi_os_printf(const char *fmt, ...)
70 {
71 va_list args;
72 va_start(args, fmt);
73 acpi_os_vprintf(fmt, args);
74 va_end(args);
75 }
77 void acpi_os_vprintf(const char *fmt, va_list args)
78 {
79 static char buffer[512];
81 vsnprintf(buffer, sizeof(buffer), fmt, args);
83 printk("%s", buffer);
84 }
86 acpi_physical_address __init acpi_os_get_root_pointer(void)
87 {
88 #ifdef __ia64__
89 if (efi_enabled) {
90 if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
91 return efi.acpi20;
92 else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
93 return efi.acpi;
94 else {
95 printk(KERN_ERR PREFIX
96 "System description tables not found\n");
97 return 0;
98 }
99 } else
100 #endif
101 {
102 acpi_physical_address pa = 0;
104 acpi_find_root_pointer(&pa);
105 return pa;
106 }
107 }
109 void __iomem *
110 acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
111 {
112 return __acpi_map_table((unsigned long)phys, size);
113 }
114 EXPORT_SYMBOL_GPL(acpi_os_map_memory);
116 void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
117 {
118 }
119 EXPORT_SYMBOL_GPL(acpi_os_unmap_memory);
121 acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
122 {
123 u32 dummy;
125 if (!value)
126 value = &dummy;
128 *value = 0;
129 if (width <= 8) {
130 *(u8 *) value = inb(port);
131 } else if (width <= 16) {
132 *(u16 *) value = inw(port);
133 } else if (width <= 32) {
134 *(u32 *) value = inl(port);
135 } else {
136 BUG();
137 }
139 return AE_OK;
140 }
142 EXPORT_SYMBOL(acpi_os_read_port);
144 acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
145 {
146 if (width <= 8) {
147 outb(value, port);
148 } else if (width <= 16) {
149 outw(value, port);
150 } else if (width <= 32) {
151 outl(value, port);
152 } else {
153 BUG();
154 }
156 return AE_OK;
157 }
159 EXPORT_SYMBOL(acpi_os_write_port);
161 acpi_status
162 acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
163 {
164 u32 dummy;
165 void __iomem *virt_addr;
167 virt_addr = map_domain_page(phys_addr>>PAGE_SHIFT);
168 if (!value)
169 value = &dummy;
171 switch (width) {
172 case 8:
173 *(u8 *) value = readb(virt_addr);
174 break;
175 case 16:
176 *(u16 *) value = readw(virt_addr);
177 break;
178 case 32:
179 *(u32 *) value = readl(virt_addr);
180 break;
181 default:
182 BUG();
183 }
185 unmap_domain_page(virt_addr);
187 return AE_OK;
188 }
190 acpi_status
191 acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
192 {
193 void __iomem *virt_addr;
195 virt_addr = map_domain_page(phys_addr>>PAGE_SHIFT);
197 switch (width) {
198 case 8:
199 writeb(value, virt_addr);
200 break;
201 case 16:
202 writew(value, virt_addr);
203 break;
204 case 32:
205 writel(value, virt_addr);
206 break;
207 default:
208 BUG();
209 }
211 unmap_domain_page(virt_addr);
213 return AE_OK;
214 }
216 /*
217 * Acquire a spinlock.
218 *
219 * handle is a pointer to the spinlock_t.
220 */
222 acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
223 {
224 acpi_cpu_flags flags;
225 spin_lock_irqsave(lockp, flags);
226 return flags;
227 }
229 /*
230 * Release a spinlock. See above.
231 */
233 void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
234 {
235 spin_unlock_irqrestore(lockp, flags);
236 }