Deleted Added
full compact
acpi.c (133935) acpi.c (136128)
1/*-
2 * Copyright (c) 1998 Doug Rabson
3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*-
2 * Copyright (c) 1998 Doug Rabson
3 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/usr.sbin/acpi/acpidump/acpi.c 133935 2004-08-18 05:56:07Z njl $
27 * $FreeBSD: head/usr.sbin/acpi/acpidump/acpi.c 136128 2004-10-05 02:18:53Z njl $
28 */
29
30#include <sys/param.h>
31#include <sys/endian.h>
32#include <sys/stat.h>
33#include <sys/wait.h>
34#include <assert.h>
35#include <err.h>

--- 678 unchanged lines hidden (view full) ---

714 if (memcmp(rsdp->signature, "XSDT", 4) != 0 ||
715 acpi_checksum(rsdp, rsdp->len) != 0)
716 errx(1, "XSDT is corrupted");
717 addr_size = sizeof(uint64_t);
718 }
719 return (rsdp);
720}
721
28 */
29
30#include <sys/param.h>
31#include <sys/endian.h>
32#include <sys/stat.h>
33#include <sys/wait.h>
34#include <assert.h>
35#include <err.h>

--- 678 unchanged lines hidden (view full) ---

714 if (memcmp(rsdp->signature, "XSDT", 4) != 0 ||
715 acpi_checksum(rsdp, rsdp->len) != 0)
716 errx(1, "XSDT is corrupted");
717 addr_size = sizeof(uint64_t);
718 }
719 return (rsdp);
720}
721
722/* Write the DSDT to a file, concatenating any SSDTs (if present). */
722static int
723write_dsdt(int fd, struct ACPIsdt *rsdt, struct ACPIsdt *dsdt)
724{
725 struct ACPIsdt sdt;
726 struct ACPIsdt *ssdt;
727 uint8_t sum;
728
723static int
724write_dsdt(int fd, struct ACPIsdt *rsdt, struct ACPIsdt *dsdt)
725{
726 struct ACPIsdt sdt;
727 struct ACPIsdt *ssdt;
728 uint8_t sum;
729
730 /* Create a new checksum to account for the DSDT and any SSDTs. */
729 sdt = *dsdt;
730 if (rsdt != NULL) {
731 sdt.check = 0;
732 sum = acpi_checksum(dsdt->body, dsdt->len - SIZEOF_SDT_HDR);
733 ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL);
731 sdt = *dsdt;
732 if (rsdt != NULL) {
733 sdt.check = 0;
734 sum = acpi_checksum(dsdt->body, dsdt->len - SIZEOF_SDT_HDR);
735 ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL);
734 while (ssdt != NULL) {
736 while (sflag && ssdt != NULL) {
735 sdt.len += ssdt->len - SIZEOF_SDT_HDR;
736 sum += acpi_checksum(ssdt->body,
737 ssdt->len - SIZEOF_SDT_HDR);
738 ssdt = sdt_from_rsdt(rsdt, "SSDT", ssdt);
739 }
740 sum += acpi_checksum(&sdt, SIZEOF_SDT_HDR);
741 sdt.check -= sum;
742 }
737 sdt.len += ssdt->len - SIZEOF_SDT_HDR;
738 sum += acpi_checksum(ssdt->body,
739 ssdt->len - SIZEOF_SDT_HDR);
740 ssdt = sdt_from_rsdt(rsdt, "SSDT", ssdt);
741 }
742 sum += acpi_checksum(&sdt, SIZEOF_SDT_HDR);
743 sdt.check -= sum;
744 }
745
746 /* Write out the DSDT header and body. */
743 write(fd, &sdt, SIZEOF_SDT_HDR);
744 write(fd, dsdt->body, dsdt->len - SIZEOF_SDT_HDR);
747 write(fd, &sdt, SIZEOF_SDT_HDR);
748 write(fd, dsdt->body, dsdt->len - SIZEOF_SDT_HDR);
745 if (rsdt != NULL) {
749
750 /* Write out any SSDTs (if present and the user requested this.) */
751 if (sflag && rsdt != NULL) {
746 ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL);
747 while (ssdt != NULL) {
748 write(fd, ssdt->body, ssdt->len - SIZEOF_SDT_HDR);
749 ssdt = sdt_from_rsdt(rsdt, "SSDT", ssdt);
750 }
751 }
752 return (0);
753}

--- 114 unchanged lines hidden ---
752 ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL);
753 while (ssdt != NULL) {
754 write(fd, ssdt->body, ssdt->len - SIZEOF_SDT_HDR);
755 ssdt = sdt_from_rsdt(rsdt, "SSDT", ssdt);
756 }
757 }
758 return (0);
759}

--- 114 unchanged lines hidden ---