aboutsummaryrefslogtreecommitdiff
path: root/source/compiler/aslcompile.c
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2013-02-15 19:12:35 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2013-02-15 19:12:35 +0000
commit6bb10c5e2fa82c104e57c7468335930ba9e47d4f (patch)
tree60bd49061ad572a9f0cd0955d91e302983ee6939 /source/compiler/aslcompile.c
parenta8e5af903d1868804e09dfa39195b9bb1826ace2 (diff)
downloadsrc-6bb10c5e2fa82c104e57c7468335930ba9e47d4f.tar.gz
src-6bb10c5e2fa82c104e57c7468335930ba9e47d4f.zip
Import ACPICA 20130215.vendor/acpica/20130214
Notes
Notes: svn path=/vendor-sys/acpica/dist/; revision=246847 svn path=/vendor-sys/acpica/20130214/; revision=246848; tag=vendor/acpica/20130214
Diffstat (limited to 'source/compiler/aslcompile.c')
-rw-r--r--source/compiler/aslcompile.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c
index af7e1b8c03be..c7528704f92a 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