From owner-p4-projects Wed Dec 4 14:38:26 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CACF237B401; Wed, 4 Dec 2002 14:38:20 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5CC6D37B401 for ; Wed, 4 Dec 2002 14:38:20 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 04B2943E88 for ; Wed, 4 Dec 2002 14:38:20 -0800 (PST) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id gB4MY3mV029122 for ; Wed, 4 Dec 2002 14:34:03 -0800 (PST) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id gB4MY2rT029119 for perforce@freebsd.org; Wed, 4 Dec 2002 14:34:02 -0800 (PST) Date: Wed, 4 Dec 2002 14:34:02 -0800 (PST) Message-Id: <200212042234.gB4MY2rT029119@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar Subject: PERFORCE change 21937 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://perforce.freebsd.org/chv.cgi?CH=21937 Change 21937 by marcel@marcel_nfs on 2002/12/04 14:33:45 Deal with secundary SDTs: o the dump file (as specified with -o) is created on the first call to aml_dump(), but appended on successive calls. This allows use to save both DSDT and SSDTs. o To dump from file (as specified with -f), we need to take into account that it can contain multiple fragments. We will use the headers to deal with that. o The DSDT printing and AML parsing has been reorganized to allow for multiple DSDTs (by means of the SSDTs), without multple initializations and/or printing of headers. Yes, this is kludgy. Affected files ... .. //depot/projects/ia64/usr.sbin/acpi/acpidump/acpi.c#6 edit .. //depot/projects/ia64/usr.sbin/acpi/acpidump/acpi_user.c#4 edit .. //depot/projects/ia64/usr.sbin/acpi/acpidump/acpidump.c#7 edit .. //depot/projects/ia64/usr.sbin/acpi/acpidump/aml_dump.c#2 edit Differences ... ==== //depot/projects/ia64/usr.sbin/acpi/acpidump/acpi.c#6 (text+ko) ==== @@ -102,11 +102,12 @@ u_int8_t *dp; u_int8_t *end; - acpi_print_dsdt(dsdp); + acpi_print_sdt(dsdp); dp = (u_int8_t *)dsdp->body; end = (u_int8_t *)dsdp + dsdp->len; acpi_dump_dsdt(dp, end); + aml_dump(dsdp); } static void @@ -122,7 +123,6 @@ if (acpi_checksum(dsdp, dsdp->len)) errx(1, "DSDT is corrupt\n"); acpi_handle_dsdt(dsdp); - aml_dump(dsdp); } static void @@ -136,7 +136,7 @@ newname = aml_create_name(&env, "\\_OS_"); newname->property = aml_alloc_object(aml_t_string, NULL); newname->property->str.needfree = 0; - newname->property->str.string = "Microsoft Windows NT"; + newname->property->str.string = "FreeBSD"; } /* @@ -148,10 +148,7 @@ { extern struct aml_environ asl_env; - acpi_print_dsdt_definition(); - /* 1st stage: parse only w/o printing */ - init_namespace(); aml_new_name_group((uintptr_t)dp); bzero(&asl_env, sizeof(asl_env)); @@ -192,6 +189,7 @@ printf(END_COMMENT); if (!memcmp(sdp->signature, "DSDT", 4)) { memcpy(&dsdt_header, sdp, sizeof(dsdt_header)); + acpi_print_dsdt_definition(); } } @@ -284,13 +282,6 @@ printf(END_COMMENT); } -void -acpi_print_dsdt(struct ACPIsdt *dsdp) -{ - - acpi_print_sdt(dsdp); -} - int acpi_checksum(void *p, size_t length) { @@ -352,6 +343,8 @@ printf(" }\n"); printf(END_COMMENT); + init_namespace(); + p = (void*)rsdp->body; while (p < end) { if (rsdp->signature[0] == 'X') { @@ -367,6 +360,8 @@ if (!memcmp(sdp->signature, "FACP", 4)) { acpi_handle_facp((struct FACPbody *)sdp->body, (rsdp->signature[0] == 'X') ? 1 : 0); + } else if (!memcmp(sdp->signature, "SSDT", 4)) { + acpi_handle_dsdt(sdp); } else acpi_print_sdt(sdp); } ==== //depot/projects/ia64/usr.sbin/acpi/acpidump/acpi_user.c#4 (text+ko) ==== @@ -160,11 +160,8 @@ errx(1, "mmap %s\n", dumpfile); } - if (strncmp(dp, "DSDT", 4) == 0) { + if (strncmp(dp, "DSDT", 4) == 0) memcpy(&dsdt_header, dp, SIZEOF_SDT_HDR); - dp += SIZEOF_SDT_HDR; - sb.st_size -= SIZEOF_SDT_HDR; - } end = (u_int8_t *) dp + sb.st_size; *dpp = dp; ==== //depot/projects/ia64/usr.sbin/acpi/acpidump/acpidump.c#7 (text+ko) ==== @@ -43,10 +43,14 @@ { u_int8_t *dp; u_int8_t *end; - struct ACPIsdt *dsdt; + struct ACPIsdt *dsdp; acpi_load_dsdt(file, &dp, &end); - acpi_dump_dsdt(dp, end); + while (dp != end) { + dsdp = (void*)dp; + dp += dsdp->len; + acpi_dump_dsdt((char*)dsdp->body, dp); + } } void ==== //depot/projects/ia64/usr.sbin/acpi/acpidump/aml_dump.c#2 (text+ko) ==== @@ -38,23 +38,29 @@ char *aml_dumpfile = NULL; +/* + * Deal with secundary SDTs by appending to the dump file on successive + * calls to aml_dump(). + */ +int aml_append = 0; + void aml_dump(struct ACPIsdt *dsdp) { - int fd; + int fd, flags; mode_t mode; if (aml_dumpfile == NULL) { return; } + flags = O_WRONLY | ((!aml_append) ? O_CREAT|O_TRUNC : O_APPEND); mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - fd = open(aml_dumpfile, O_WRONLY | O_CREAT | O_TRUNC, mode); - if (fd == -1) { + fd = open(aml_dumpfile, flags, mode); + if (fd == -1) return; - } write(fd, dsdp, SIZEOF_SDT_HDR); write(fd, dsdp->body, dsdp->len - SIZEOF_SDT_HDR); close(fd); + aml_append = 1; } - To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message