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.
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include <contrib/dev/acpica/include/acpi.h>
32 #define APIC_IO_SAPIC 6
33 #define APIC_LOCAL_SAPIC 7
37 typedef struct /* LOCAL SAPIC */
39 ACPI_SUBTABLE_HEADER Header;
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 */
50 ACPI_SUBTABLE_HEADER Header;
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 */
62 ACPI_MADT_LOCAL_SAPIC cpu0;
63 ACPI_MADT_LOCAL_SAPIC cpu1;
64 ACPI_MADT_LOCAL_SAPIC cpu2;
65 ACPI_MADT_LOCAL_SAPIC cpu3;
66 ACPI_MADT_IO_SAPIC sapic;
70 ACPI_SIG_MADT, /* Signature. */
71 sizeof(apic), /* Length of table. */
72 0, /* ACPI minor revision. */
75 "SKI", /* OEM table Id. */
76 0, /* OEM revision. */
77 "FBSD", /* ASL compiler Id. */
78 0, /* ASL revision. */
83 APIC_LOCAL_SAPIC, /* Type. */
84 sizeof(apic.cpu0), /* Length. */
85 0, /* ACPI processor id */
86 0, /* Processor local SAPIC id */
87 0, /* Processor local SAPIC eid */
93 APIC_LOCAL_SAPIC, /* Type. */
94 sizeof(apic.cpu1), /* Length. */
95 1, /* ACPI processor id */
96 0, /* Processor local SAPIC id */
97 1, /* Processor local SAPIC eid */
103 APIC_LOCAL_SAPIC, /* Type. */
104 sizeof(apic.cpu2), /* Length. */
105 2, /* ACPI processor id */
106 1, /* Processor local SAPIC id */
107 0, /* Processor local SAPIC eid */
109 0, /* FL: Enabled. */
113 APIC_LOCAL_SAPIC, /* Type. */
114 sizeof(apic.cpu3), /* Length. */
115 3, /* ACPI processor id */
116 1, /* Processor local SAPIC id */
117 1, /* Processor local SAPIC eid */
119 0, /* FL: Enabled. */
123 APIC_IO_SAPIC, /* Type. */
124 sizeof(apic.sapic), /* Length. */
125 4, /* IO SAPIC id. */
127 16, /* Interrupt base. */
128 0xfec00000 /* IO SAPIC address. */
133 ACPI_TABLE_HEADER Header;
137 ACPI_SIG_XSDT, /* Signature. */
138 sizeof(xsdt), /* Length of table. */
139 0, /* ACPI minor revision. */
140 0, /* XXX checksum. */
141 "FBSD", /* OEM Id. */
142 "SKI", /* OEM table Id. */
143 0, /* OEM revision. */
144 "FBSD", /* ASL compiler Id. */
145 0 /* ASL revision. */
147 0UL /* XXX APIC table address. */
150 ACPI_TABLE_RSDP acpi_root = {
152 0, /* XXX checksum. */
154 2, /* ACPI Rev 2.0. */
156 sizeof(xsdt), /* XSDT length. */
157 0UL, /* XXX PA of XSDT. */
158 0, /* XXX Extended checksum. */
162 cksum(void *addr, int sz, UINT8 *sum)
176 acpi_root.XsdtPhysicalAddress = (UINT64)&xsdt;
177 cksum(&acpi_root, 20, &acpi_root.Checksum);
178 cksum(&acpi_root, sizeof(acpi_root), &acpi_root.ExtendedChecksum);
180 cksum(&apic, sizeof(apic), &apic.MADT.Header.Checksum);
181 xsdt.apic_tbl = (UINT32)&apic;
182 cksum(&xsdt, sizeof(xsdt), &xsdt.Header.Checksum);