| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: acpi_machdep.c,v 1.26 2019/05/01 07:26:28 mlelstv Exp $ */ | | 1 | /* $NetBSD: acpi_machdep.c,v 1.26.2.1 2019/09/17 19:41:45 martin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 2001 Wasabi Systems, Inc. | | 4 | * Copyright 2001 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -30,27 +30,27 @@ | | | @@ -30,27 +30,27 @@ |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | * POSSIBILITY OF SUCH DAMAGE. | | 35 | * POSSIBILITY OF SUCH DAMAGE. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | /* | | 38 | /* |
39 | * Machine-dependent routines for ACPICA. | | 39 | * Machine-dependent routines for ACPICA. |
40 | */ | | 40 | */ |
41 | | | 41 | |
42 | #include <sys/cdefs.h> | | 42 | #include <sys/cdefs.h> |
43 | __KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.26 2019/05/01 07:26:28 mlelstv Exp $"); | | 43 | __KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.26.2.1 2019/09/17 19:41:45 martin Exp $"); |
44 | | | 44 | |
45 | #include <sys/param.h> | | 45 | #include <sys/param.h> |
46 | #include <sys/systm.h> | | 46 | #include <sys/systm.h> |
47 | #include <sys/bus.h> | | 47 | #include <sys/bus.h> |
48 | #include <sys/cpu.h> | | 48 | #include <sys/cpu.h> |
49 | #include <sys/device.h> | | 49 | #include <sys/device.h> |
50 | | | 50 | |
51 | #include <uvm/uvm_extern.h> | | 51 | #include <uvm/uvm_extern.h> |
52 | | | 52 | |
53 | #include <machine/cpufunc.h> | | 53 | #include <machine/cpufunc.h> |
54 | #include <machine/bootinfo.h> | | 54 | #include <machine/bootinfo.h> |
55 | #include <machine/autoconf.h> | | 55 | #include <machine/autoconf.h> |
56 | | | 56 | |
| @@ -90,37 +90,95 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_machdep | | | @@ -90,37 +90,95 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_machdep |
90 | | | 90 | |
91 | ACPI_STATUS | | 91 | ACPI_STATUS |
92 | acpi_md_OsInitialize(void) | | 92 | acpi_md_OsInitialize(void) |
93 | { | | 93 | { |
94 | return AE_OK; | | 94 | return AE_OK; |
95 | } | | 95 | } |
96 | | | 96 | |
97 | ACPI_PHYSICAL_ADDRESS | | 97 | ACPI_PHYSICAL_ADDRESS |
98 | acpi_md_OsGetRootPointer(void) | | 98 | acpi_md_OsGetRootPointer(void) |
99 | { | | 99 | { |
100 | ACPI_PHYSICAL_ADDRESS PhysicalAddress; | | 100 | ACPI_PHYSICAL_ADDRESS PhysicalAddress; |
101 | ACPI_STATUS Status; | | 101 | ACPI_STATUS Status; |
102 | | | 102 | |
103 | #ifndef XENPV | | 103 | #ifdef XENPV |
104 | /* If EFI is available, attempt to use it to locate the ACPI table. */ | | 104 | /* |
| | | 105 | * Obtain the ACPI RSDP from the hypervisor. |
| | | 106 | * This is the only way to go if Xen booted from EFI: the |
| | | 107 | * Extended BIOS Data Area (EBDA) is not mapped, and Xen |
| | | 108 | * does not pass an EFI SystemTable to the kernel. |
| | | 109 | */ |
| | | 110 | struct xen_platform_op op = { |
| | | 111 | .cmd = XENPF_firmware_info, |
| | | 112 | .u.firmware_info = { |
| | | 113 | .type = XEN_FW_EFI_INFO, |
| | | 114 | .index = XEN_FW_EFI_CONFIG_TABLE |
| | | 115 | } |
| | | 116 | }; |
| | | 117 | union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info; |
| | | 118 | |
| | | 119 | if (HYPERVISOR_platform_op(&op) == 0) { |
| | | 120 | struct efi_cfgtbl *ct; |
| | | 121 | int i; |
| | | 122 | |
| | | 123 | ct = AcpiOsMapMemory(info->cfg.addr, |
| | | 124 | sizeof(*ct) * info->cfg.nent); |
| | | 125 | |
| | | 126 | for (i = 0; i < info->cfg.nent; i++) { |
| | | 127 | if (memcmp(&ct[i].ct_uuid, |
| | | 128 | &EFI_UUID_ACPI20, sizeof(EFI_UUID_ACPI20)) == 0) { |
| | | 129 | PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) |
| | | 130 | (uintptr_t)ct[i].ct_data; |
| | | 131 | if (PhysicalAddress) |
| | | 132 | goto out; |
| | | 133 | |
| | | 134 | } |
| | | 135 | } |
| | | 136 | |
| | | 137 | for (i = 0; i < info->cfg.nent; i++) { |
| | | 138 | if (memcmp(&ct[i].ct_uuid, |
| | | 139 | &EFI_UUID_ACPI10, sizeof(EFI_UUID_ACPI10)) == 0) { |
| | | 140 | PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) |
| | | 141 | (uintptr_t)ct[i].ct_data; |
| | | 142 | if (PhysicalAddress) |
| | | 143 | goto out; |
| | | 144 | |
| | | 145 | } |
| | | 146 | } |
| | | 147 | out: |
| | | 148 | AcpiOsUnmapMemory(ct, sizeof(*ct) * info->cfg.nent); |
| | | 149 | |
| | | 150 | if (PhysicalAddress) |
| | | 151 | return PhysicalAddress; |
| | | 152 | } |
| | | 153 | #else |
| | | 154 | /* |
| | | 155 | * Get the ACPI RSDP from EFI SystemTable. This works when the |
| | | 156 | * kernel was loaded from EFI bootloader. |
| | | 157 | */ |
105 | if (efi_probe()) { | | 158 | if (efi_probe()) { |
106 | PhysicalAddress = efi_getcfgtblpa(&EFI_UUID_ACPI20); | | 159 | PhysicalAddress = efi_getcfgtblpa(&EFI_UUID_ACPI20); |
107 | if (!PhysicalAddress) | | 160 | if (!PhysicalAddress) |
108 | PhysicalAddress = efi_getcfgtblpa(&EFI_UUID_ACPI10); | | 161 | PhysicalAddress = efi_getcfgtblpa(&EFI_UUID_ACPI10); |
109 | if (PhysicalAddress) | | 162 | if (PhysicalAddress) |
110 | return PhysicalAddress; | | 163 | return PhysicalAddress; |
111 | } | | 164 | } |
112 | | | 165 | |
113 | #endif | | 166 | #endif |
| | | 167 | /* |
| | | 168 | * Find ACPI RSDP from Extended BIOS Data Area (EBDA). This |
| | | 169 | * works when the kernel was started from BIOS bootloader, |
| | | 170 | * or for Xen PV when Xen was started from BIOS bootloader. |
| | | 171 | */ |
114 | Status = AcpiFindRootPointer(&PhysicalAddress); | | 172 | Status = AcpiFindRootPointer(&PhysicalAddress); |
115 | if (ACPI_FAILURE(Status)) | | 173 | if (ACPI_FAILURE(Status)) |
116 | PhysicalAddress = 0; | | 174 | PhysicalAddress = 0; |
117 | | | 175 | |
118 | return PhysicalAddress; | | 176 | return PhysicalAddress; |
119 | } | | 177 | } |
120 | | | 178 | |
121 | struct acpi_md_override { | | 179 | struct acpi_md_override { |
122 | int irq; | | 180 | int irq; |
123 | int pin; | | 181 | int pin; |
124 | int flags; | | 182 | int flags; |
125 | }; | | 183 | }; |
126 | | | 184 | |