Add the -s flag to make dumping SSDTs optional (disabled by default).

Since we can only override the DSDT, a custom ASL dumped previously that
contained SSDTs would result in lots of multiple definition errors.

A longer-term fix involves adding the ability to override SSDTs to ACPI-CA.

MFC after:	3 days
This commit is contained in:
Nate Lawson 2004-10-05 02:18:53 +00:00
parent 842ba60ee2
commit 62c7bde198
3 changed files with 16 additions and 5 deletions

View File

@ -719,6 +719,7 @@ sdt_load_devmem(void)
return (rsdp); return (rsdp);
} }
/* Write the DSDT to a file, concatenating any SSDTs (if present). */
static int static int
write_dsdt(int fd, struct ACPIsdt *rsdt, struct ACPIsdt *dsdt) write_dsdt(int fd, struct ACPIsdt *rsdt, struct ACPIsdt *dsdt)
{ {
@ -726,12 +727,13 @@ write_dsdt(int fd, struct ACPIsdt *rsdt, struct ACPIsdt *dsdt)
struct ACPIsdt *ssdt; struct ACPIsdt *ssdt;
uint8_t sum; uint8_t sum;
/* Create a new checksum to account for the DSDT and any SSDTs. */
sdt = *dsdt; sdt = *dsdt;
if (rsdt != NULL) { if (rsdt != NULL) {
sdt.check = 0; sdt.check = 0;
sum = acpi_checksum(dsdt->body, dsdt->len - SIZEOF_SDT_HDR); sum = acpi_checksum(dsdt->body, dsdt->len - SIZEOF_SDT_HDR);
ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL); ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL);
while (ssdt != NULL) { while (sflag && ssdt != NULL) {
sdt.len += ssdt->len - SIZEOF_SDT_HDR; sdt.len += ssdt->len - SIZEOF_SDT_HDR;
sum += acpi_checksum(ssdt->body, sum += acpi_checksum(ssdt->body,
ssdt->len - SIZEOF_SDT_HDR); ssdt->len - SIZEOF_SDT_HDR);
@ -740,9 +742,13 @@ write_dsdt(int fd, struct ACPIsdt *rsdt, struct ACPIsdt *dsdt)
sum += acpi_checksum(&sdt, SIZEOF_SDT_HDR); sum += acpi_checksum(&sdt, SIZEOF_SDT_HDR);
sdt.check -= sum; sdt.check -= sum;
} }
/* Write out the DSDT header and body. */
write(fd, &sdt, SIZEOF_SDT_HDR); write(fd, &sdt, SIZEOF_SDT_HDR);
write(fd, dsdt->body, dsdt->len - SIZEOF_SDT_HDR); write(fd, dsdt->body, dsdt->len - SIZEOF_SDT_HDR);
if (rsdt != NULL) {
/* Write out any SSDTs (if present and the user requested this.) */
if (sflag && rsdt != NULL) {
ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL); ssdt = sdt_from_rsdt(rsdt, "SSDT", NULL);
while (ssdt != NULL) { while (ssdt != NULL) {
write(fd, ssdt->body, ssdt->len - SIZEOF_SDT_HDR); write(fd, ssdt->body, ssdt->len - SIZEOF_SDT_HDR);

View File

@ -37,6 +37,7 @@
#include "acpidump.h" #include "acpidump.h"
int dflag; /* Disassemble AML using iasl(8) */ int dflag; /* Disassemble AML using iasl(8) */
int sflag; /* Include secondary (SSDT) tables. */
int tflag; /* Dump contents of SDT tables */ int tflag; /* Dump contents of SDT tables */
int vflag; /* Use verbose messages */ int vflag; /* Use verbose messages */
@ -44,7 +45,7 @@ static void
usage(const char *progname) usage(const char *progname)
{ {
fprintf(stderr, "usage: %s [-d] [-t] [-h] [-v] [-f dsdt_input] " fprintf(stderr, "usage: %s [-d] [-s] [-t] [-h] [-v] [-f dsdt_input] "
"[-o dsdt_output]\n", progname); "[-o dsdt_output]\n", progname);
exit(1); exit(1);
} }
@ -62,11 +63,14 @@ main(int argc, char *argv[])
if (argc < 2) if (argc < 2)
usage(progname); usage(progname);
while ((c = getopt(argc, argv, "dhtvf:o:")) != -1) { while ((c = getopt(argc, argv, "dhstvf:o:")) != -1) {
switch (c) { switch (c) {
case 'd': case 'd':
dflag = 1; dflag = 1;
break; break;
case 's':
sflag = 1;
break;
case 't': case 't':
tflag = 1; tflag = 1;
break; break;
@ -122,7 +126,7 @@ main(int argc, char *argv[])
rsdt = NULL; rsdt = NULL;
} }
/* Dump the DSDT to a file */ /* Dump the DSDT and SSDTs to a file */
if (dsdt_output_file != NULL) { if (dsdt_output_file != NULL) {
if (vflag) if (vflag)
warnx("saving DSDT file: %s", dsdt_output_file); warnx("saving DSDT file: %s", dsdt_output_file);

View File

@ -332,6 +332,7 @@ int acpi_checksum(void *, size_t);
/* Command line flags */ /* Command line flags */
extern int dflag; extern int dflag;
extern int sflag;
extern int tflag; extern int tflag;
extern int vflag; extern int vflag;