mirror of
https://github.com/acpica/acpica/
synced 2025-02-05 16:14:06 +03:00
iASL: Implement wildcard support for -e option (get external tables).
This change implements wildcard support for this option. It also removes the local implementation of wildcard expansion. This part affects the windows version only. Windows version is now linked to the setargv.obj library to get this support.
This commit is contained in:
parent
1ce28e58d5
commit
93c1c10009
@ -86,7 +86,7 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/LTCG"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib setargv.obj"
|
||||
OutputFile=".\AslCompiler\AslCompiler.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
@ -189,7 +189,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib setargv.obj"
|
||||
OutputFile=".\AslCompilerDebug\AslCompiler.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
@ -198,6 +198,7 @@
|
||||
ProgramDatabaseFile=".\AslCompilerDebug\AslCompiler.pdb"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary=""
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
|
@ -351,48 +351,41 @@ Cleanup:
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiDmAddToExternalFileList (
|
||||
char *PathList)
|
||||
char *Pathname)
|
||||
{
|
||||
ACPI_EXTERNAL_FILE *ExternalFile;
|
||||
char *Path;
|
||||
char *TmpPath;
|
||||
char *LocalPathname;
|
||||
|
||||
|
||||
if (!PathList)
|
||||
if (!Pathname)
|
||||
{
|
||||
return (AE_OK);
|
||||
}
|
||||
|
||||
Path = strtok (PathList, ",");
|
||||
|
||||
while (Path)
|
||||
LocalPathname = ACPI_ALLOCATE (strlen (Pathname) + 1);
|
||||
if (!LocalPathname)
|
||||
{
|
||||
TmpPath = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (Path) + 1);
|
||||
if (!TmpPath)
|
||||
{
|
||||
return (AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
ACPI_STRCPY (TmpPath, Path);
|
||||
|
||||
ExternalFile = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_FILE));
|
||||
if (!ExternalFile)
|
||||
{
|
||||
ACPI_FREE (TmpPath);
|
||||
return (AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
ExternalFile->Path = TmpPath;
|
||||
|
||||
if (AcpiGbl_ExternalFileList)
|
||||
{
|
||||
ExternalFile->Next = AcpiGbl_ExternalFileList;
|
||||
}
|
||||
|
||||
AcpiGbl_ExternalFileList = ExternalFile;
|
||||
Path = strtok (NULL, ",");
|
||||
return (AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
ExternalFile = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EXTERNAL_FILE));
|
||||
if (!ExternalFile)
|
||||
{
|
||||
ACPI_FREE (LocalPathname);
|
||||
return (AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
/* Take a copy of the file pathname */
|
||||
|
||||
strcpy (LocalPathname, Pathname);
|
||||
ExternalFile->Path = LocalPathname;
|
||||
|
||||
if (AcpiGbl_ExternalFileList)
|
||||
{
|
||||
ExternalFile->Next = AcpiGbl_ExternalFileList;
|
||||
}
|
||||
|
||||
AcpiGbl_ExternalFileList = ExternalFile;
|
||||
return (AE_OK);
|
||||
}
|
||||
|
||||
|
@ -194,11 +194,6 @@ typedef
|
||||
ACPI_STATUS (*ASL_PATHNAME_CALLBACK) (
|
||||
char *);
|
||||
|
||||
ACPI_STATUS
|
||||
AslDoOnePathname (
|
||||
char *Pathname,
|
||||
ASL_PATHNAME_CALLBACK Callback);
|
||||
|
||||
ACPI_STATUS
|
||||
AslDoOneFile (
|
||||
char *Filename);
|
||||
|
@ -123,6 +123,17 @@
|
||||
#define _COMPONENT ACPI_COMPILER
|
||||
ACPI_MODULE_NAME ("aslmain")
|
||||
|
||||
/*
|
||||
* Main routine for the iASL compiler.
|
||||
*
|
||||
* Portability note: The compiler depends upon the host for command-line
|
||||
* wildcard support - it is not implemented locally. For example:
|
||||
*
|
||||
* Linux/Unix systems: Shell expands wildcards automatically.
|
||||
*
|
||||
* Windows: The setargv.obj module must be linked in to automatically
|
||||
* expand wildcards.
|
||||
*/
|
||||
|
||||
/* Local prototypes */
|
||||
|
||||
@ -203,13 +214,13 @@ Usage (
|
||||
ACPI_OPTION ("-vt", "Create verbose template files (full disassembly)");
|
||||
|
||||
printf ("\nAML Disassembler:\n");
|
||||
ACPI_OPTION ("-d <f1,f2>", "Disassemble or decode binary ACPI tables to file (*.dsl)");
|
||||
ACPI_OPTION ("-d <f1 f2 ...>", "Disassemble or decode binary ACPI tables to file (*.dsl)");
|
||||
ACPI_OPTION ("", " (Optional, file type is automatically detected)");
|
||||
ACPI_OPTION ("-da <f1,f2>", "Disassemble multiple tables from single namespace");
|
||||
ACPI_OPTION ("-da <f1 f2 ...>", "Disassemble multiple tables from single namespace");
|
||||
ACPI_OPTION ("-db", "Do not translate Buffers to Resource Templates");
|
||||
ACPI_OPTION ("-dc <f1,f2>", "Disassemble AML and immediately compile it");
|
||||
ACPI_OPTION ("-dc <f1 f2 ...>", "Disassemble AML and immediately compile it");
|
||||
ACPI_OPTION ("", " (Obtain DSDT from current system if no input file)");
|
||||
ACPI_OPTION ("-e <f1,f2>", "Include ACPI table(s) for external symbol resolution");
|
||||
ACPI_OPTION ("-e <f1 f2 ...>", "Include ACPI table(s) for external symbol resolution");
|
||||
ACPI_OPTION ("-fe <file>", "Specify external symbol declaration file");
|
||||
ACPI_OPTION ("-g", "Get ACPI tables and write to files (*.dat)");
|
||||
ACPI_OPTION ("-in", "Ignore NoOp opcodes");
|
||||
@ -393,7 +404,7 @@ main (
|
||||
{
|
||||
while (argv[Index1])
|
||||
{
|
||||
Status = AslDoOnePathname (argv[Index1], AcpiDmAddToExternalFileList);
|
||||
Status = AcpiDmAddToExternalFileList (argv[Index1]);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (-1);
|
||||
@ -407,7 +418,16 @@ main (
|
||||
|
||||
while (argv[Index2])
|
||||
{
|
||||
Status = AslDoOnePathname (argv[Index2], AslDoOneFile);
|
||||
/*
|
||||
* If -p not specified, we will use the input filename as the
|
||||
* output filename prefix
|
||||
*/
|
||||
if (Gbl_UseDefaultAmlFilename)
|
||||
{
|
||||
Gbl_OutputFilenamePrefix = argv[Index2];
|
||||
}
|
||||
|
||||
Status = AslDoOneFile (argv[Index2]);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (-1);
|
||||
|
@ -339,11 +339,21 @@ AslDoOptions (
|
||||
|
||||
case 'e': /* External files for disassembler */
|
||||
|
||||
Status = AcpiDmAddToExternalFileList (AcpiGbl_Optarg);
|
||||
if (ACPI_FAILURE (Status))
|
||||
/* Get entire list of external files */
|
||||
|
||||
AcpiGbl_Optind--;
|
||||
|
||||
while (argv[AcpiGbl_Optind] &&
|
||||
(argv[AcpiGbl_Optind][0] != '-'))
|
||||
{
|
||||
printf ("Could not add %s to external list\n", AcpiGbl_Optarg);
|
||||
return (-1);
|
||||
Status = AcpiDmAddToExternalFileList (argv[AcpiGbl_Optind]);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
printf ("Could not add %s to external list\n", argv[AcpiGbl_Optind]);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
AcpiGbl_Optind++;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -123,18 +123,8 @@
|
||||
ACPI_MODULE_NAME ("aslstartup")
|
||||
|
||||
|
||||
#define ASL_MAX_FILES 256
|
||||
static char *FileList[ASL_MAX_FILES];
|
||||
static BOOLEAN AslToFile = TRUE;
|
||||
|
||||
|
||||
/* Local prototypes */
|
||||
|
||||
static char **
|
||||
AsDoWildcard (
|
||||
char *DirectoryPathname,
|
||||
char *FileSpecifier);
|
||||
|
||||
static UINT8
|
||||
AslDetectSourceFileType (
|
||||
ASL_FILE_INFO *Info);
|
||||
@ -144,6 +134,11 @@ AslDoDisassembly (
|
||||
void);
|
||||
|
||||
|
||||
/* Globals */
|
||||
|
||||
static BOOLEAN AslToFile = TRUE;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AslInitializeGlobals
|
||||
@ -203,82 +198,6 @@ AslInitializeGlobals (
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AsDoWildcard
|
||||
*
|
||||
* PARAMETERS: None
|
||||
*
|
||||
* RETURN: None
|
||||
*
|
||||
* DESCRIPTION: Process files via wildcards. This function is for the Windows
|
||||
* case only.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
static char **
|
||||
AsDoWildcard (
|
||||
char *DirectoryPathname,
|
||||
char *FileSpecifier)
|
||||
{
|
||||
#ifdef WIN32
|
||||
void *DirInfo;
|
||||
char *Filename;
|
||||
int FileCount;
|
||||
|
||||
|
||||
FileCount = 0;
|
||||
|
||||
/* Open parent directory */
|
||||
|
||||
DirInfo = AcpiOsOpenDirectory (DirectoryPathname, FileSpecifier, REQUEST_FILE_ONLY);
|
||||
if (!DirInfo)
|
||||
{
|
||||
/* Either the directory of file does not exist */
|
||||
|
||||
Gbl_Files[ASL_FILE_INPUT].Filename = FileSpecifier;
|
||||
FlFileError (ASL_FILE_INPUT, ASL_MSG_OPEN);
|
||||
AslAbort ();
|
||||
}
|
||||
|
||||
/* Process each file that matches the wildcard specification */
|
||||
|
||||
while ((Filename = AcpiOsGetNextFilename (DirInfo)))
|
||||
{
|
||||
/* Add the filename to the file list */
|
||||
|
||||
FileList[FileCount] = AcpiOsAllocate (strlen (Filename) + 1);
|
||||
strcpy (FileList[FileCount], Filename);
|
||||
FileCount++;
|
||||
|
||||
if (FileCount >= ASL_MAX_FILES)
|
||||
{
|
||||
printf ("Max files reached\n");
|
||||
FileList[0] = NULL;
|
||||
return (FileList);
|
||||
}
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
|
||||
AcpiOsCloseDirectory (DirInfo);
|
||||
FileList[FileCount] = NULL;
|
||||
return (FileList);
|
||||
|
||||
#else
|
||||
/*
|
||||
* Linux/Unix cases - Wildcards are expanded by the shell automatically.
|
||||
* Just return the filename in a null terminated list
|
||||
*/
|
||||
FileList[0] = AcpiOsAllocate (strlen (FileSpecifier) + 1);
|
||||
strcpy (FileList[0], FileSpecifier);
|
||||
FileList[1] = NULL;
|
||||
|
||||
return (FileList);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AslDetectSourceFileType
|
||||
@ -613,77 +532,6 @@ AslDoOneFile (
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AslDoOnePathname
|
||||
*
|
||||
* PARAMETERS: Pathname - Full pathname, possibly with wildcards
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Process one pathname, possible terminated with a wildcard
|
||||
* specification. If a wildcard, it is expanded and the multiple
|
||||
* files are processed.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AslDoOnePathname (
|
||||
char *Pathname,
|
||||
ASL_PATHNAME_CALLBACK PathCallback)
|
||||
{
|
||||
ACPI_STATUS Status = AE_OK;
|
||||
char **WildcardList;
|
||||
char *Filename;
|
||||
char *FullPathname;
|
||||
|
||||
|
||||
/* Split incoming path into a directory/filename combo */
|
||||
|
||||
Status = FlSplitInputPathname (Pathname, &Gbl_DirectoryPath, &Filename);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (Status);
|
||||
}
|
||||
|
||||
/* Expand possible wildcard into a file list (Windows/DOS only) */
|
||||
|
||||
WildcardList = AsDoWildcard (Gbl_DirectoryPath, Filename);
|
||||
while (*WildcardList)
|
||||
{
|
||||
FullPathname = ACPI_ALLOCATE (
|
||||
strlen (Gbl_DirectoryPath) + strlen (*WildcardList) + 1);
|
||||
|
||||
/* Construct a full path to the file */
|
||||
|
||||
strcpy (FullPathname, Gbl_DirectoryPath);
|
||||
strcat (FullPathname, *WildcardList);
|
||||
|
||||
/*
|
||||
* If -p not specified, we will use the input filename as the
|
||||
* output filename prefix
|
||||
*/
|
||||
if (Gbl_UseDefaultAmlFilename)
|
||||
{
|
||||
Gbl_OutputFilenamePrefix = FullPathname;
|
||||
}
|
||||
|
||||
/* Save status from all compiles */
|
||||
|
||||
Status |= (*PathCallback) (FullPathname);
|
||||
|
||||
ACPI_FREE (FullPathname);
|
||||
ACPI_FREE (*WildcardList);
|
||||
*WildcardList = NULL;
|
||||
WildcardList++;
|
||||
}
|
||||
|
||||
ACPI_FREE (Gbl_DirectoryPath);
|
||||
ACPI_FREE (Filename);
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AslCheckForErrorExit
|
||||
|
@ -564,7 +564,7 @@ AcpiDbReadTableFromFile (
|
||||
File = fopen (Filename, "rb");
|
||||
if (!File)
|
||||
{
|
||||
AcpiOsPrintf ("Could not open input file %s\n", Filename);
|
||||
perror ("Could not open input file");
|
||||
return (AE_ERROR);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user