2 * Copyright (c) 2003 Marcel Moolenaar
5 * Redistribution and use in source and binary forms, with or without
6 * 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 WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * $FreeBSD: src/sys/boot/ia64/libski/acpi_stub.c,v 1.2 2003/09/08 09:11:32 obrien Exp $
27 * $DragonFly: src/sys/boot/ia64/libski/acpi_stub.c,v 1.2 2007/01/19 07:23:42 dillon Exp $
30 #include <contrib/dev/acpica/acpi.h>
32 #define APIC_IO_SAPIC 6
33 #define APIC_LOCAL_SAPIC 7
37 typedef struct /* LOCAL SAPIC */
40 UINT8 ProcessorId; /* ACPI processor id */
41 UINT8 LocalSapicId; /* Processor local SAPIC id */
42 UINT8 LocalSapicEid; /* Processor local SAPIC eid */
44 UINT32 ProcessorEnabled: 1;
45 UINT32 FlagsReserved: 31;
48 typedef struct /* IO SAPIC */
51 UINT8 IoSapicId; /* I/O SAPIC ID */
52 UINT8 Reserved; /* reserved - must be zero */
53 UINT32 Vector; /* interrupt base */
54 UINT64 IoSapicAddress; /* SAPIC's physical address */
71 APIC_SIG, /* Signature. */
72 sizeof(apic), /* Length of table. */
73 0, /* ACPI minor revision. */
74 0, /* XXX checksum. */
76 "SKI", /* OEM table Id. */
77 0, /* OEM revision. */
78 "FBSD", /* ASL compiler Id. */
86 APIC_LOCAL_SAPIC, /* Type. */
87 sizeof(apic.cpu0) /* Length. */
89 0, /* ACPI processor id */
90 0, /* Processor local SAPIC id */
91 0, /* Processor local SAPIC eid */
98 APIC_LOCAL_SAPIC, /* Type. */
99 sizeof(apic.cpu1) /* Length. */
101 1, /* ACPI processor id */
102 0, /* Processor local SAPIC id */
103 1, /* Processor local SAPIC eid */
105 1, /* FL: Enabled. */
110 APIC_LOCAL_SAPIC, /* Type. */
111 sizeof(apic.cpu2) /* Length. */
113 2, /* ACPI processor id */
114 1, /* Processor local SAPIC id */
115 0, /* Processor local SAPIC eid */
117 0, /* FL: Enabled. */
122 APIC_LOCAL_SAPIC, /* Type. */
123 sizeof(apic.cpu3) /* Length. */
125 3, /* ACPI processor id */
126 1, /* Processor local SAPIC id */
127 1, /* Processor local SAPIC eid */
129 0, /* FL: Enabled. */
134 APIC_IO_SAPIC, /* Type. */
135 sizeof(apic.sapic) /* Length. */
137 4, /* IO SAPIC id. */
139 16, /* Interrupt base. */
140 0xfec00000 /* IO SAPIC address. */
145 ACPI_TABLE_HEADER Header;
149 XSDT_SIG, /* Signature. */
150 sizeof(xsdt), /* Length of table. */
151 0, /* ACPI minor revision. */
152 0, /* XXX checksum. */
153 "FBSD", /* OEM Id. */
154 "SKI", /* OEM table Id. */
155 0, /* OEM revision. */
156 "FBSD", /* ASL compiler Id. */
157 0 /* ASL revision. */
159 NULL /* XXX APIC table address. */
162 ACPI_TABLE_RSDP acpi_root = {
164 0, /* XXX checksum. */
166 2, /* ACPI Rev 2.0. */
168 sizeof(xsdt), /* XSDT length. */
169 NULL, /* XXX PA of XSDT. */
170 0, /* XXX Extended checksum. */
174 cksum(void *addr, int sz, UINT8 *sum)
188 acpi_root.XsdtPhysicalAddress = (UINT64)&xsdt;
189 cksum(&acpi_root, 20, &acpi_root.Checksum);
190 cksum(&acpi_root, sizeof(acpi_root), &acpi_root.ExtendedChecksum);
192 xsdt.apic_tbl = (UINT32)&apic;
193 cksum(&xsdt, sizeof(xsdt), &xsdt.Header.Checksum);