Message ID | 1342676948-21368-1-git-send-email-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
On 07/19/2012 01:49 PM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > When loading ACPI tables from raw files using the -t option load the > table name from the table signature rather than using the filename. > We need to ensure we cater for the RSD PTR and also normal ACPI table > signatures correctly too. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/lib/src/fwts_acpi_tables.c | 23 +++++++++++++++++++---- > 1 file changed, 19 insertions(+), 4 deletions(-) > > diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c > index bd47e99..4db5844 100644 > --- a/src/lib/src/fwts_acpi_tables.c > +++ b/src/lib/src/fwts_acpi_tables.c > @@ -484,14 +484,29 @@ static int fwts_acpi_load_tables_from_file(fwts_framework *fw) > if ((fd = open(path, O_RDONLY)) >= 0) { > uint8_t *table; > size_t length; > - char name[PATH_MAX]; > > - strcpy(name, dir_entries[i]->d_name); > - name[strlen(name)-4] = '\0'; > - if ((table = fwts_acpi_load_table_from_file(fd, &length)) != NULL) > + if ((table = fwts_acpi_load_table_from_file(fd, &length)) != NULL) { > + char name[9]; /* "RSD PTR " or standard ACPI 4 letter name */ > + > + fwts_acpi_table_rsdp *rsdp = (fwts_acpi_table_rsdp *)table; > + > + /* Could be RSDP or a standard ACPI table, so check */ > + > + if (!strncmp(rsdp->signature, "RSD PTR ", 8)) { > + /* In fwts, RSD PTR is tagged as the RSDP */ > + strcpy(name, "RSDP"); > + } else { > + /* Assume it is a standard ACPI table */ > + fwts_acpi_table_header *hdr = (fwts_acpi_table_header *)table; > + > + strncpy(name, hdr->signature, 4); > + name[4] = '\0'; > + } > + > fwts_acpi_add_table(name, table, > (uint64_t)fwts_fake_physical_addr(length), length, > FWTS_ACPI_TABLE_FROM_FILE); > + } > close(fd); > } else > fwts_log_error(fw, "Cannot load ACPI table from file '%s'\n", path); > Acked-by: Ivan Hu<ivan.hu@canonical.com>
On Thu, Jul 19, 2012 at 1:49 PM, Colin King <colin.king@canonical.com> wrote: > From: Colin Ian King <colin.king@canonical.com> > > When loading ACPI tables from raw files using the -t option load the > table name from the table signature rather than using the filename. > We need to ensure we cater for the RSD PTR and also normal ACPI table > signatures correctly too. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/lib/src/fwts_acpi_tables.c | 23 +++++++++++++++++++---- > 1 file changed, 19 insertions(+), 4 deletions(-) > > diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c > index bd47e99..4db5844 100644 > --- a/src/lib/src/fwts_acpi_tables.c > +++ b/src/lib/src/fwts_acpi_tables.c > @@ -484,14 +484,29 @@ static int fwts_acpi_load_tables_from_file(fwts_framework *fw) > if ((fd = open(path, O_RDONLY)) >= 0) { > uint8_t *table; > size_t length; > - char name[PATH_MAX]; > > - strcpy(name, dir_entries[i]->d_name); > - name[strlen(name)-4] = '\0'; > - if ((table = fwts_acpi_load_table_from_file(fd, &length)) != NULL) > + if ((table = fwts_acpi_load_table_from_file(fd, &length)) != NULL) { > + char name[9]; /* "RSD PTR " or standard ACPI 4 letter name */ > + > + fwts_acpi_table_rsdp *rsdp = (fwts_acpi_table_rsdp *)table; > + > + /* Could be RSDP or a standard ACPI table, so check */ > + > + if (!strncmp(rsdp->signature, "RSD PTR ", 8)) { > + /* In fwts, RSD PTR is tagged as the RSDP */ > + strcpy(name, "RSDP"); > + } else { > + /* Assume it is a standard ACPI table */ > + fwts_acpi_table_header *hdr = (fwts_acpi_table_header *)table; > + > + strncpy(name, hdr->signature, 4); > + name[4] = '\0'; > + } > + > fwts_acpi_add_table(name, table, > (uint64_t)fwts_fake_physical_addr(length), length, > FWTS_ACPI_TABLE_FROM_FILE); > + } > close(fd); > } else > fwts_log_error(fw, "Cannot load ACPI table from file '%s'\n", path); > -- > 1.7.10.4 > Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c index bd47e99..4db5844 100644 --- a/src/lib/src/fwts_acpi_tables.c +++ b/src/lib/src/fwts_acpi_tables.c @@ -484,14 +484,29 @@ static int fwts_acpi_load_tables_from_file(fwts_framework *fw) if ((fd = open(path, O_RDONLY)) >= 0) { uint8_t *table; size_t length; - char name[PATH_MAX]; - strcpy(name, dir_entries[i]->d_name); - name[strlen(name)-4] = '\0'; - if ((table = fwts_acpi_load_table_from_file(fd, &length)) != NULL) + if ((table = fwts_acpi_load_table_from_file(fd, &length)) != NULL) { + char name[9]; /* "RSD PTR " or standard ACPI 4 letter name */ + + fwts_acpi_table_rsdp *rsdp = (fwts_acpi_table_rsdp *)table; + + /* Could be RSDP or a standard ACPI table, so check */ + + if (!strncmp(rsdp->signature, "RSD PTR ", 8)) { + /* In fwts, RSD PTR is tagged as the RSDP */ + strcpy(name, "RSDP"); + } else { + /* Assume it is a standard ACPI table */ + fwts_acpi_table_header *hdr = (fwts_acpi_table_header *)table; + + strncpy(name, hdr->signature, 4); + name[4] = '\0'; + } + fwts_acpi_add_table(name, table, (uint64_t)fwts_fake_physical_addr(length), length, FWTS_ACPI_TABLE_FROM_FILE); + } close(fd); } else fwts_log_error(fw, "Cannot load ACPI table from file '%s'\n", path);