3 * Copyright (c) 2009 KIYOHARA Takashi
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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
;
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 */
63 acpi_md_OsTerminate(void)
67 printf("%s\n", __func__
);
72 acpi_md_OsGetRootPointer(void)
76 if (acpi_root_phys
== 0) {
77 acpi_root
= efi_get_table(&acpi20_table
);
78 if (acpi_root
== NULL
)
80 acpi_root_phys
= IA64_RR_MASK((u_long
)acpi_root
);
83 return acpi_root_phys
;
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,
99 if (has_i8259
&& InterruptNumber
< 16)
100 irq
= isa_irq_to_vector_map
[InterruptNumber
];
102 irq
= InterruptNumber
;
105 * XXX probably, IPL_BIO is enough.
107 ih
= intr_establish(irq
, IST_LEVEL
, IPL_TTY
,
108 (int (*)(void *)) ServiceRoutine
, Context
);
116 acpi_md_OsRemoveInterruptHandler(void *cookie
)
119 intr_disestablish(cookie
);
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)
135 acpi_md_OsUnmapMemory(void *LogicalAddress
, UINT32 Length
)
138 bus_space_unmap(IA64_BUS_SPACE_MEM
, (bus_space_handle_t
) LogicalAddress
,
143 acpi_md_OsGetPhysicalAddress(void *LogicalAddress
,
144 ACPI_PHYSICAL_ADDRESS
*PhysicalAddress
)
148 printf("%s\n", __func__
);
149 if (pmap_extract(pmap_kernel(), (vaddr_t
) LogicalAddress
, &pa
)) {
150 *PhysicalAddress
= pa
;
158 acpi_md_OsReadable(void *Pointer
, UINT32 Length
)
161 printf("%s: not yet...\n", __func__
);
167 acpi_md_OsWritable(void *Pointer
, UINT32 Length
)
170 printf("%s: not yet...\n", __func__
);
175 acpi_md_OsEnableInterrupt(void)
182 acpi_md_OsDisableInterrupt(void)
189 acpi_md_callback(void)
197 acpi_md_sleep(int state
)
199 printf("%s: not yet...\n", __func__
);
206 printf("%s: not yet...\n", __func__
);