| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: acpi.c,v 1.16 2017/08/04 06:30:36 msaitoh Exp $ */ | | 1 | /* $NetBSD: acpi.c,v 1.17 2017/08/18 09:49:24 msaitoh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1998 Doug Rabson | | 4 | * Copyright (c) 1998 Doug Rabson |
5 | * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org> | | 5 | * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org> |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | | 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 | * SUCH DAMAGE. | | 27 | * SUCH DAMAGE. |
28 | * | | 28 | * |
29 | * $FreeBSD: head/usr.sbin/acpi/acpidump/acpi.c 321299 2017-07-20 17:36:17Z emaste $ | | 29 | * $FreeBSD: head/usr.sbin/acpi/acpidump/acpi.c 321299 2017-07-20 17:36:17Z emaste $ |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __RCSID("$NetBSD: acpi.c,v 1.16 2017/08/04 06:30:36 msaitoh Exp $"); | | 33 | __RCSID("$NetBSD: acpi.c,v 1.17 2017/08/18 09:49:24 msaitoh Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/endian.h> | | 36 | #include <sys/endian.h> |
37 | #include <sys/stat.h> | | 37 | #include <sys/stat.h> |
38 | #include <sys/wait.h> | | 38 | #include <sys/wait.h> |
39 | #include <assert.h> | | 39 | #include <assert.h> |
40 | #include <err.h> | | 40 | #include <err.h> |
41 | #include <fcntl.h> | | 41 | #include <fcntl.h> |
42 | #include <paths.h> | | 42 | #include <paths.h> |
43 | #include <stdio.h> | | 43 | #include <stdio.h> |
44 | #include <stdint.h> | | 44 | #include <stdint.h> |
45 | #include <stdlib.h> | | 45 | #include <stdlib.h> |
46 | #include <string.h> | | 46 | #include <string.h> |
| @@ -765,26 +765,28 @@ acpi_handle_fadt(ACPI_TABLE_HEADER *sdp) | | | @@ -765,26 +765,28 @@ acpi_handle_fadt(ACPI_TABLE_HEADER *sdp) |
765 | fadt_revision = acpi_get_fadt_revision(fadt); | | 765 | fadt_revision = acpi_get_fadt_revision(fadt); |
766 | if (fadt_revision == 1) | | 766 | if (fadt_revision == 1) |
767 | facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->Facs); | | 767 | facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->Facs); |
768 | else | | 768 | else |
769 | facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->XFacs); | | 769 | facs = (ACPI_TABLE_FACS *)acpi_map_sdt(fadt->XFacs); |
770 | if (memcmp(facs->Signature, ACPI_SIG_FACS, 4) != 0 || facs->Length < 64) | | 770 | if (memcmp(facs->Signature, ACPI_SIG_FACS, 4) != 0 || facs->Length < 64) |
771 | errx(EXIT_FAILURE, "FACS is corrupt"); | | 771 | errx(EXIT_FAILURE, "FACS is corrupt"); |
772 | acpi_print_facs(facs); | | 772 | acpi_print_facs(facs); |
773 | | | 773 | |
774 | if (fadt_revision == 1) | | 774 | if (fadt_revision == 1) |
775 | dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->Dsdt); | | 775 | dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->Dsdt); |
776 | else | | 776 | else |
777 | dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->XDsdt); | | 777 | dsdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(fadt->XDsdt); |
| | | 778 | if (memcmp(dsdp->Signature, ACPI_SIG_DSDT, 4) != 0) |
| | | 779 | errx(EXIT_FAILURE, "DSDT signature mismatch"); |
778 | if (acpi_checksum(dsdp, dsdp->Length)) | | 780 | if (acpi_checksum(dsdp, dsdp->Length)) |
779 | errx(EXIT_FAILURE, "DSDT is corrupt"); | | 781 | errx(EXIT_FAILURE, "DSDT is corrupt"); |
780 | acpi_print_dsdt(dsdp); | | 782 | acpi_print_dsdt(dsdp); |
781 | } | | 783 | } |
782 | | | 784 | |
783 | static void | | 785 | static void |
784 | acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first, | | 786 | acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first, |
785 | void (*action)(ACPI_SUBTABLE_HEADER *)) | | 787 | void (*action)(ACPI_SUBTABLE_HEADER *)) |
786 | { | | 788 | { |
787 | ACPI_SUBTABLE_HEADER *subtable; | | 789 | ACPI_SUBTABLE_HEADER *subtable; |
788 | char *end; | | 790 | char *end; |
789 | | | 791 | |
790 | subtable = first; | | 792 | subtable = first; |