Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / ia64 / acpi / acpi_machdep.c
blob46e3b2df671c92bf4cca6b7865fd5abacd7819ba
1 /* $NetBSD$ */
2 /*
3 * Copyright (c) 2009 KIYOHARA Takashi
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
28 * Machine-dependent routines for ACPICA.
30 #include <sys/cdefs.h>
31 __KERNEL_RCSID(0, "$NetBSD$");
33 #include <sys/param.h>
35 #include <uvm/uvm_extern.h>
37 #include <machine/bus.h>
38 #include <machine/efi.h>
39 #include <machine/intrdefs.h>
41 #include <dev/acpi/acpica.h>
42 #include <dev/acpi/acpivar.h>
44 #include <machine/acpi_machdep.h>
47 static struct uuid acpi20_table = EFI_TABLE_ACPI20;
48 static u_long acpi_root_phys;
49 int has_i8259 = 0;
52 ACPI_STATUS
53 acpi_md_OsInitialize(void)
56 if (((ia64_get_cpuid(3) >> 24) & 0xff) == 0x07)
57 has_i8259 = 1; /* Firmware on old Itanium systems is broken */
59 return AE_OK;
62 ACPI_STATUS
63 acpi_md_OsTerminate(void)
66 /* nothing to do. */
67 printf("%s\n", __func__);
68 return AE_OK;
71 ACPI_PHYSICAL_ADDRESS
72 acpi_md_OsGetRootPointer(void)
74 void *acpi_root;
76 if (acpi_root_phys == 0) {
77 acpi_root = efi_get_table(&acpi20_table);
78 if (acpi_root == NULL)
79 return 0;
80 acpi_root_phys = IA64_RR_MASK((u_long)acpi_root);
83 return acpi_root_phys;
86 ACPI_STATUS
87 acpi_md_OsInstallInterruptHandler(UINT32 InterruptNumber,
88 ACPI_OSD_HANDLER ServiceRoutine,
89 void *Context, void **cookiep)
91 static int isa_irq_to_vector_map[16] = {
92 /* i8259 IRQ translation, first 16 entries */
93 0x2f, 0x20, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29,
94 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21,
96 int irq;
97 void *ih;
99 if (has_i8259 && InterruptNumber < 16)
100 irq = isa_irq_to_vector_map[InterruptNumber];
101 else
102 irq = InterruptNumber;
105 * XXX probably, IPL_BIO is enough.
107 ih = intr_establish(irq, IST_LEVEL, IPL_TTY,
108 (int (*)(void *)) ServiceRoutine, Context);
109 if (ih == NULL)
110 return AE_NO_MEMORY;
111 *cookiep = ih;
112 return AE_OK;
115 void
116 acpi_md_OsRemoveInterruptHandler(void *cookie)
119 intr_disestablish(cookie);
122 ACPI_STATUS
123 acpi_md_OsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, UINT32 Length,
124 void **LogicalAddress)
127 if (bus_space_map(IA64_BUS_SPACE_MEM, PhysicalAddress, Length,
128 0, (bus_space_handle_t *) LogicalAddress) == 0)
129 return AE_OK;
131 return AE_NO_MEMORY;
134 void
135 acpi_md_OsUnmapMemory(void *LogicalAddress, UINT32 Length)
138 bus_space_unmap(IA64_BUS_SPACE_MEM, (bus_space_handle_t) LogicalAddress,
139 Length);
142 ACPI_STATUS
143 acpi_md_OsGetPhysicalAddress(void *LogicalAddress,
144 ACPI_PHYSICAL_ADDRESS *PhysicalAddress)
146 paddr_t pa;
148 printf("%s\n", __func__);
149 if (pmap_extract(pmap_kernel(), (vaddr_t) LogicalAddress, &pa)) {
150 *PhysicalAddress = pa;
151 return AE_OK;
154 return AE_ERROR;
157 BOOLEAN
158 acpi_md_OsReadable(void *Pointer, UINT32 Length)
160 BOOLEAN rv = TRUE;
161 printf("%s: not yet...\n", __func__);
163 return rv;
166 BOOLEAN
167 acpi_md_OsWritable(void *Pointer, UINT32 Length)
169 BOOLEAN rv = FALSE;
170 printf("%s: not yet...\n", __func__);
171 return rv;
174 void
175 acpi_md_OsEnableInterrupt(void)
178 enable_intr();
181 void
182 acpi_md_OsDisableInterrupt(void)
185 disable_intr();
188 void
189 acpi_md_callback(void)
192 /* nothing */
197 acpi_md_sleep(int state)
199 printf("%s: not yet...\n", __func__);
200 return 0;
203 void
204 wbinvd(void)
206 printf("%s: not yet...\n", __func__);