diff options
author | jkim <jkim@FreeBSD.org> | 2013-02-15 19:12:35 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2013-02-15 19:12:35 +0000 |
commit | bd5edd68a8fda8df18c688919e100f7f1df5ad6b (patch) | |
tree | 60bd49061ad572a9f0cd0955d91e302983ee6939 /source/compiler/aslcompile.c | |
parent | 713ce6817a3fbfd4bf492408e97d9b7468853c17 (diff) | |
download | FreeBSD-src-bd5edd68a8fda8df18c688919e100f7f1df5ad6b.zip FreeBSD-src-bd5edd68a8fda8df18c688919e100f7f1df5ad6b.tar.gz |
Import ACPICA 20130215.
Diffstat (limited to 'source/compiler/aslcompile.c')
-rw-r--r-- | source/compiler/aslcompile.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index af7e1b8..c752870 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -42,6 +42,7 @@ */ #include "aslcompiler.h" +#include "dtcompiler.h" #include <stdio.h> #include <time.h> @@ -343,6 +344,89 @@ FlConsumeNewComment ( /******************************************************************************* * + * FUNCTION: FlCheckForAcpiTable + * + * PARAMETERS: Handle - Open input file + * + * RETURN: Status + * + * DESCRIPTION: Determine if a file seems to be a binary ACPI table, via the + * following checks on what would be the table header: + * 0) File must be at least as long as an ACPI_TABLE_HEADER + * 1) The header length field must match the file size + * 2) Signature, OemId, OemTableId, AslCompilerId must be ASCII + * + ******************************************************************************/ + +ACPI_STATUS +FlCheckForAcpiTable ( + FILE *Handle) +{ + ACPI_TABLE_HEADER Table; + UINT32 FileSize; + size_t Actual; + UINT32 i; + + + /* Read a potential table header */ + + Actual = fread (&Table, 1, sizeof (ACPI_TABLE_HEADER), Handle); + fseek (Handle, 0, SEEK_SET); + + if (Actual < sizeof (ACPI_TABLE_HEADER)) + { + return (AE_ERROR); + } + + /* Header length field must match the file size */ + + FileSize = DtGetFileSize (Handle); + if (Table.Length != FileSize) + { + return (AE_ERROR); + } + + /* + * These fields must be ASCII: + * Signature, OemId, OemTableId, AslCompilerId. + * We allow a NULL terminator in OemId and OemTableId. + */ + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.Signature[i])) + { + return (AE_ERROR); + } + + if (!ACPI_IS_ASCII ((UINT8) Table.AslCompilerId[i])) + { + return (AE_ERROR); + } + } + + for (i = 0; (i < ACPI_OEM_ID_SIZE) && (Table.OemId[i]); i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.OemId[i])) + { + return (AE_ERROR); + } + } + + for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (Table.OemTableId[i]); i++) + { + if (!ACPI_IS_ASCII ((UINT8) Table.OemTableId[i])) + { + return (AE_ERROR); + } + } + + printf ("Binary file appears to be a valid ACPI table, disassembling\n"); + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: FlCheckForAscii * * PARAMETERS: Handle - Open input file |