summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/compiler/aslfiles.c
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2013-01-17 23:56:43 +0000
committerjkim <jkim@FreeBSD.org>2013-01-17 23:56:43 +0000
commit2a54ee62b3fb5d0e9bf39d81edd2cc14a56166a4 (patch)
treea7cdf321edb5a438878660c0df9e9bf8a70038e1 /sys/contrib/dev/acpica/compiler/aslfiles.c
parent39b667a9d0968b8b54185d03b5b8bb2670346424 (diff)
parent8f7c8be022add76a280165a4247448f1fcd77631 (diff)
downloadFreeBSD-src-2a54ee62b3fb5d0e9bf39d81edd2cc14a56166a4.zip
FreeBSD-src-2a54ee62b3fb5d0e9bf39d81edd2cc14a56166a4.tar.gz
Merge ACPICA 20130117.
Diffstat (limited to 'sys/contrib/dev/acpica/compiler/aslfiles.c')
-rw-r--r--sys/contrib/dev/acpica/compiler/aslfiles.c350
1 files changed, 2 insertions, 348 deletions
diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c
index 39f64b7..a525fc2 100644
--- a/sys/contrib/dev/acpica/compiler/aslfiles.c
+++ b/sys/contrib/dev/acpica/compiler/aslfiles.c
@@ -1,11 +1,11 @@
/******************************************************************************
*
- * Module Name: aslfiles - file I/O suppoert
+ * Module Name: aslfiles - File support functions
*
*****************************************************************************/
/*
- * Copyright (C) 2000 - 2012, Intel Corp.
+ * Copyright (C) 2000 - 2013, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -64,352 +64,6 @@ FlParseInputPathname (
/*******************************************************************************
*
- * FUNCTION: AslAbort
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Dump the error log and abort the compiler. Used for serious
- * I/O errors
- *
- ******************************************************************************/
-
-void
-AslAbort (
- void)
-{
-
- AePrintErrorLog (ASL_FILE_STDERR);
- if (Gbl_DebugFlag)
- {
- /* Print error summary to stdout also */
-
- AePrintErrorLog (ASL_FILE_STDOUT);
- }
-
- exit (1);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: FlFileError
- *
- * PARAMETERS: FileId - Index into file info array
- * ErrorId - Index into error message array
- *
- * RETURN: None
- *
- * DESCRIPTION: Decode errno to an error message and add the entire error
- * to the error log.
- *
- ******************************************************************************/
-
-void
-FlFileError (
- UINT32 FileId,
- UINT8 ErrorId)
-{
-
- sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename,
- strerror (errno));
- AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: FlOpenFile
- *
- * PARAMETERS: FileId - Index into file info array
- * Filename - file pathname to open
- * Mode - Open mode for fopen
- *
- * RETURN: None
- *
- * DESCRIPTION: Open a file.
- * NOTE: Aborts compiler on any error.
- *
- ******************************************************************************/
-
-void
-FlOpenFile (
- UINT32 FileId,
- char *Filename,
- char *Mode)
-{
- FILE *File;
-
-
- File = fopen (Filename, Mode);
- if (!File)
- {
- FlFileError (FileId, ASL_MSG_OPEN);
- AslAbort ();
- }
-
- Gbl_Files[FileId].Filename = Filename;
- Gbl_Files[FileId].Handle = File;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: FlGetFileSize
- *
- * PARAMETERS: FileId - Index into file info array
- *
- * RETURN: File Size
- *
- * DESCRIPTION: Get current file size. Uses seek-to-EOF. File must be open.
- *
- ******************************************************************************/
-
-UINT32
-FlGetFileSize (
- UINT32 FileId)
-{
- FILE *fp;
- UINT32 FileSize;
- long Offset;
-
-
- fp = Gbl_Files[FileId].Handle;
- Offset = ftell (fp);
-
- fseek (fp, 0, SEEK_END);
- FileSize = (UINT32) ftell (fp);
-
- /* Restore file pointer */
-
- fseek (fp, Offset, SEEK_SET);
- return (FileSize);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: FlReadFile
- *
- * PARAMETERS: FileId - Index into file info array
- * Buffer - Where to place the data
- * Length - Amount to read
- *
- * RETURN: Status. AE_ERROR indicates EOF.
- *
- * DESCRIPTION: Read data from an open file.
- * NOTE: Aborts compiler on any error.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-FlReadFile (
- UINT32 FileId,
- void *Buffer,
- UINT32 Length)
-{
- UINT32 Actual;
-
-
- /* Read and check for error */
-
- Actual = fread (Buffer, 1, Length, Gbl_Files[FileId].Handle);
- if (Actual < Length)
- {
- if (feof (Gbl_Files[FileId].Handle))
- {
- /* End-of-file, just return error */
-
- return (AE_ERROR);
- }
-
- FlFileError (FileId, ASL_MSG_READ);
- AslAbort ();
- }
-
- return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: FlWriteFile
- *
- * PARAMETERS: FileId - Index into file info array
- * Buffer - Data to write
- * Length - Amount of data to write
- *
- * RETURN: None
- *
- * DESCRIPTION: Write data to an open file.
- * NOTE: Aborts compiler on any error.
- *
- ******************************************************************************/
-
-void
-FlWriteFile (
- UINT32 FileId,
- void *Buffer,
- UINT32 Length)
-{
- UINT32 Actual;
-
-
- /* Write and check for error */
-
- Actual = fwrite ((char *) Buffer, 1, Length, Gbl_Files[FileId].Handle);
- if (Actual != Length)
- {
- FlFileError (FileId, ASL_MSG_WRITE);
- AslAbort ();
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: FlPrintFile
- *
- * PARAMETERS: FileId - Index into file info array
- * Format - Printf format string
- * ... - Printf arguments
- *
- * RETURN: None
- *
- * DESCRIPTION: Formatted write to an open file.
- * NOTE: Aborts compiler on any error.
- *
- ******************************************************************************/
-
-void
-FlPrintFile (
- UINT32 FileId,
- char *Format,
- ...)
-{
- INT32 Actual;
- va_list Args;
-
-
- va_start (Args, Format);
-
- Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args);
- va_end (Args);
-
- if (Actual == -1)
- {
- FlFileError (FileId, ASL_MSG_WRITE);
- AslAbort ();
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: FlSeekFile
- *
- * PARAMETERS: FileId - Index into file info array
- * Offset - Absolute byte offset in file
- *
- * RETURN: None
- *
- * DESCRIPTION: Seek to absolute offset
- * NOTE: Aborts compiler on any error.
- *
- ******************************************************************************/
-
-void
-FlSeekFile (
- UINT32 FileId,
- long Offset)
-{
- int Error;
-
-
- Error = fseek (Gbl_Files[FileId].Handle, Offset, SEEK_SET);
- if (Error)
- {
- FlFileError (FileId, ASL_MSG_SEEK);
- AslAbort ();
- }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: FlCloseFile
- *
- * PARAMETERS: FileId - Index into file info array
- *
- * RETURN: None
- *
- * DESCRIPTION: Close an open file. Aborts compiler on error
- *
- ******************************************************************************/
-
-void
-FlCloseFile (
- UINT32 FileId)
-{
- int Error;
-
-
- if (!Gbl_Files[FileId].Handle)
- {
- return;
- }
-
- Error = fclose (Gbl_Files[FileId].Handle);
- if (Error)
- {
- FlFileError (FileId, ASL_MSG_CLOSE);
- AslAbort ();
- }
-
- Gbl_Files[FileId].Handle = NULL;
- return;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION: FlDeleteFile
- *
- * PARAMETERS: FileId - Index into file info array
- *
- * RETURN: None
- *
- * DESCRIPTION: Delete a file.
- *
- ******************************************************************************/
-
-void
-FlDeleteFile (
- UINT32 FileId)
-{
- ASL_FILE_INFO *Info = &Gbl_Files[FileId];
-
-
- if (!Info->Filename)
- {
- return;
- }
-
- if (remove (Info->Filename))
- {
- printf ("%s (%s file) ",
- Info->Filename, Info->Description);
- perror ("Could not delete");
- }
-
- Info->Filename = NULL;
- return;
-}
-
-
-/*******************************************************************************
- *
* FUNCTION: FlSetLineNumber
*
* PARAMETERS: Op - Parse node for the LINE asl statement
OpenPOWER on IntegriCloud