Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Dec 2002 14:34:02 -0800 (PST)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 21937 for review
Message-ID:  <200212042234.gB4MY2rT029119@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212042234.gB4MY2rT029119>