mirror of
https://github.com/acpica/acpica/
synced 2025-01-15 13:59:19 +03:00
New interface to OsAcquireLock and OsReleaseLock
date 2005.06.07.17.06.00; author rmoore1; state Exp;
This commit is contained in:
parent
37ccd44a64
commit
e74ee00c81
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* 1. Copyright Notice
|
* 1. Copyright Notice
|
||||||
*
|
*
|
||||||
* Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
|
* Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* 2. License
|
* 2. License
|
||||||
@ -664,12 +664,12 @@ AcpiOsDeleteLock (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
UINT32
|
||||||
AcpiOsAcquireLock (
|
AcpiOsAcquireLock (
|
||||||
ACPI_HANDLE Handle,
|
ACPI_HANDLE Handle)
|
||||||
UINT32 Flags)
|
|
||||||
{
|
{
|
||||||
AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
|
AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* Module Name: oswinxf - Windows OSL
|
* Module Name: oswinxf - Windows OSL
|
||||||
* $Revision: 1.57 $
|
* $Revision: 1.63 $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
* 1. Copyright Notice
|
* 1. Copyright Notice
|
||||||
*
|
*
|
||||||
* Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
|
* Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* 2. License
|
* 2. License
|
||||||
@ -145,7 +145,6 @@
|
|||||||
ACPI_MODULE_NAME ("oswinxf")
|
ACPI_MODULE_NAME ("oswinxf")
|
||||||
|
|
||||||
|
|
||||||
UINT32 AcpiGbl_NextSemaphore = 0;
|
|
||||||
#define NUM_SEMAPHORES 128
|
#define NUM_SEMAPHORES 128
|
||||||
|
|
||||||
typedef struct semaphore_entry
|
typedef struct semaphore_entry
|
||||||
@ -165,7 +164,7 @@ AeLocalGetRootPointer (
|
|||||||
ACPI_POINTER *Address);
|
ACPI_POINTER *Address);
|
||||||
|
|
||||||
FILE *AcpiGbl_OutputFile;
|
FILE *AcpiGbl_OutputFile;
|
||||||
LARGE_INTEGER TimerFrequency;
|
UINT64 TimerFrequency2;
|
||||||
|
|
||||||
#ifndef _ACPI_EXEC_APP
|
#ifndef _ACPI_EXEC_APP
|
||||||
/* Used by both iASL and AcpiDump applications */
|
/* Used by both iASL and AcpiDump applications */
|
||||||
@ -327,6 +326,7 @@ ACPI_STATUS
|
|||||||
AcpiOsInitialize (void)
|
AcpiOsInitialize (void)
|
||||||
{
|
{
|
||||||
UINT32 i;
|
UINT32 i;
|
||||||
|
LARGE_INTEGER TimerFrequency;
|
||||||
|
|
||||||
|
|
||||||
AcpiGbl_OutputFile = stdout;
|
AcpiGbl_OutputFile = stdout;
|
||||||
@ -336,9 +336,12 @@ AcpiOsInitialize (void)
|
|||||||
AcpiGbl_Semaphores[i].OsHandle = NULL;
|
AcpiGbl_Semaphores[i].OsHandle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!QueryPerformanceFrequency (&TimerFrequency))
|
TimerFrequency2 = 0;
|
||||||
|
if (QueryPerformanceFrequency (&TimerFrequency))
|
||||||
{
|
{
|
||||||
TimerFrequency.QuadPart = 0;
|
/* Convert ticks/sec to ticks/100nsec */
|
||||||
|
|
||||||
|
TimerFrequency2 = TimerFrequency.QuadPart / 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AE_OK;
|
return AE_OK;
|
||||||
@ -492,13 +495,12 @@ AcpiOsGetTimer (
|
|||||||
|
|
||||||
/* Attempt to use hi-granularity timer first */
|
/* Attempt to use hi-granularity timer first */
|
||||||
|
|
||||||
if (TimerFrequency.QuadPart &&
|
if (TimerFrequency2 &&
|
||||||
QueryPerformanceCounter (&Timer))
|
QueryPerformanceCounter (&Timer))
|
||||||
{
|
{
|
||||||
/* Convert to 100 nanosecond ticks */
|
/* Convert to 100 nanosecond ticks */
|
||||||
|
|
||||||
return ((UINT64) (
|
return ((UINT64) (Timer.QuadPart / TimerFrequency2));
|
||||||
(Timer.QuadPart * 10000000) / TimerFrequency.QuadPart));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fall back to the lo-granularity timer */
|
/* Fall back to the lo-granularity timer */
|
||||||
@ -818,6 +820,7 @@ AcpiOsCreateSemaphore (
|
|||||||
{
|
{
|
||||||
#ifdef _MULTI_THREADED
|
#ifdef _MULTI_THREADED
|
||||||
void *Mutex;
|
void *Mutex;
|
||||||
|
UINT32 i;
|
||||||
|
|
||||||
ACPI_FUNCTION_NAME ("OsCreateSemaphore");
|
ACPI_FUNCTION_NAME ("OsCreateSemaphore");
|
||||||
#endif
|
#endif
|
||||||
@ -840,6 +843,20 @@ AcpiOsCreateSemaphore (
|
|||||||
|
|
||||||
#ifdef _MULTI_THREADED
|
#ifdef _MULTI_THREADED
|
||||||
|
|
||||||
|
/* Find an empty slot */
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_SEMAPHORES; i++)
|
||||||
|
{
|
||||||
|
if (!AcpiGbl_Semaphores[i].OsHandle)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i >= NUM_SEMAPHORES)
|
||||||
|
{
|
||||||
|
return AE_LIMIT;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create an OS semaphore */
|
/* Create an OS semaphore */
|
||||||
|
|
||||||
Mutex = CreateSemaphore (NULL, InitialUnits, MaxUnits, NULL);
|
Mutex = CreateSemaphore (NULL, InitialUnits, MaxUnits, NULL);
|
||||||
@ -850,15 +867,14 @@ AcpiOsCreateSemaphore (
|
|||||||
return AE_NO_MEMORY;
|
return AE_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
AcpiGbl_Semaphores[AcpiGbl_NextSemaphore].MaxUnits = (UINT16) MaxUnits;
|
AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits;
|
||||||
AcpiGbl_Semaphores[AcpiGbl_NextSemaphore].CurrentUnits = (UINT16) InitialUnits;
|
AcpiGbl_Semaphores[i].CurrentUnits = (UINT16) InitialUnits;
|
||||||
AcpiGbl_Semaphores[AcpiGbl_NextSemaphore].OsHandle = Mutex;
|
AcpiGbl_Semaphores[i].OsHandle = Mutex;
|
||||||
|
|
||||||
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%d, Max=%d, Current=%d, OsHandle=%p\n",
|
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%d, Max=%d, Current=%d, OsHandle=%p\n",
|
||||||
AcpiGbl_NextSemaphore, MaxUnits, InitialUnits, Mutex));
|
i, MaxUnits, InitialUnits, Mutex));
|
||||||
|
|
||||||
*OutHandle = (void *) AcpiGbl_NextSemaphore;
|
*OutHandle = (void *) i;
|
||||||
AcpiGbl_NextSemaphore++;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return AE_OK;
|
return AE_OK;
|
||||||
@ -954,7 +970,9 @@ AcpiOsWaitSemaphore (
|
|||||||
OsTimeout = INFINITE;
|
OsTimeout = INFINITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitStatus = WaitForSingleObject (AcpiGbl_Semaphores[Index].OsHandle, OsTimeout);
|
/* Add 10ms to account for clock tick granularity */
|
||||||
|
|
||||||
|
WaitStatus = WaitForSingleObject (AcpiGbl_Semaphores[Index].OsHandle, OsTimeout+10);
|
||||||
if (WaitStatus == WAIT_TIMEOUT)
|
if (WaitStatus == WAIT_TIMEOUT)
|
||||||
{
|
{
|
||||||
/* Make optional -- wait of 0 is used to detect if unit is available
|
/* Make optional -- wait of 0 is used to detect if unit is available
|
||||||
@ -1054,12 +1072,12 @@ AcpiOsDeleteLock (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
UINT32
|
||||||
AcpiOsAcquireLock (
|
AcpiOsAcquireLock (
|
||||||
ACPI_HANDLE Handle,
|
ACPI_HANDLE Handle)
|
||||||
UINT32 Flags)
|
|
||||||
{
|
{
|
||||||
AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
|
AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1209,7 +1227,9 @@ AcpiOsSleep (
|
|||||||
ACPI_INTEGER milliseconds)
|
ACPI_INTEGER milliseconds)
|
||||||
{
|
{
|
||||||
|
|
||||||
Sleep ((unsigned long) milliseconds);
|
/* Add 10ms to account for clock tick granularity */
|
||||||
|
|
||||||
|
Sleep (((unsigned long) milliseconds) + 10);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* Module Name: abcompare - compare AML files
|
* Module Name: abcompare - compare AML files
|
||||||
* $Revision: 1.10 $
|
* $Revision: 1.19 $
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
@ -123,6 +123,95 @@ FILE *File1;
|
|||||||
FILE *File2;
|
FILE *File2;
|
||||||
ACPI_TABLE_HEADER Header1;
|
ACPI_TABLE_HEADER Header1;
|
||||||
ACPI_TABLE_HEADER Header2;
|
ACPI_TABLE_HEADER Header2;
|
||||||
|
struct stat Gbl_StatBuf;
|
||||||
|
|
||||||
|
#define BUFFER_SIZE 256
|
||||||
|
char Buffer[BUFFER_SIZE];
|
||||||
|
|
||||||
|
|
||||||
|
#define DB_CONSOLE_OUTPUT 0x02
|
||||||
|
#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01
|
||||||
|
|
||||||
|
extern FILE *AcpiGbl_DebugFile = NULL;
|
||||||
|
extern UINT8 AcpiGbl_DbOutputFlags = DB_CONSOLE_OUTPUT ;
|
||||||
|
|
||||||
|
/* Local prototypes */
|
||||||
|
|
||||||
|
static BOOLEAN
|
||||||
|
AbValidateHeader (
|
||||||
|
ACPI_TABLE_HEADER *Header);
|
||||||
|
|
||||||
|
static UINT8
|
||||||
|
AcpiTbChecksum (
|
||||||
|
void *Buffer,
|
||||||
|
UINT32 Length);
|
||||||
|
|
||||||
|
static char *
|
||||||
|
AbGetFile (
|
||||||
|
char *Filename,
|
||||||
|
UINT32 *FileSize);
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: UtHexCharToValue
|
||||||
|
*
|
||||||
|
* PARAMETERS: HexChar - Hex character in Ascii
|
||||||
|
*
|
||||||
|
* RETURN: The binary value of the hex character
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Perform ascii-to-hex translation
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
static UINT8
|
||||||
|
UtHexCharToValue (
|
||||||
|
int HexChar,
|
||||||
|
UINT8 *OutBinary)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (HexChar >= 0x30 && HexChar <= 0x39)
|
||||||
|
{
|
||||||
|
*OutBinary = (UINT8) (HexChar - 0x30);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (HexChar >= 0x41 && HexChar <= 0x46)
|
||||||
|
{
|
||||||
|
*OutBinary = (UINT8) (HexChar - 0x37);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (HexChar >= 0x61 && HexChar <= 0x66)
|
||||||
|
{
|
||||||
|
*OutBinary = (UINT8) (HexChar - 0x57);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static UINT8
|
||||||
|
AbHexByteToBinary (
|
||||||
|
char *HexString,
|
||||||
|
char *OutBinary)
|
||||||
|
{
|
||||||
|
UINT8 Local1;
|
||||||
|
UINT8 Local2;
|
||||||
|
|
||||||
|
|
||||||
|
if (!UtHexCharToValue (HexString[0], &Local1))
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
if (!UtHexCharToValue (HexString[1], &Local2))
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
*OutBinary = (UINT8) ((Local1 << 4) | Local2);
|
||||||
|
return (2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@ -133,7 +222,7 @@ ACPI_TABLE_HEADER Header2;
|
|||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
BOOLEAN
|
static BOOLEAN
|
||||||
AbValidateHeader (
|
AbValidateHeader (
|
||||||
ACPI_TABLE_HEADER *Header)
|
ACPI_TABLE_HEADER *Header)
|
||||||
{
|
{
|
||||||
@ -148,6 +237,203 @@ AbValidateHeader (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AcpiTbChecksum
|
||||||
|
*
|
||||||
|
* PARAMETERS: Buffer - Buffer to checksum
|
||||||
|
* Length - Size of the buffer
|
||||||
|
*
|
||||||
|
* RETURNS 8 bit checksum of buffer
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it.
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
static UINT8
|
||||||
|
AcpiTbChecksum (
|
||||||
|
void *Buffer,
|
||||||
|
UINT32 Length)
|
||||||
|
{
|
||||||
|
const UINT8 *limit;
|
||||||
|
const UINT8 *rover;
|
||||||
|
UINT8 sum = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if (Buffer && Length)
|
||||||
|
{
|
||||||
|
/* Buffer and Length are valid */
|
||||||
|
|
||||||
|
limit = (UINT8 *) Buffer + Length;
|
||||||
|
|
||||||
|
for (rover = Buffer; rover < limit; rover++)
|
||||||
|
{
|
||||||
|
sum = (UINT8) (sum + *rover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AbDisplayHeader
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Display an ACPI table header
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
AbDisplayHeader (
|
||||||
|
char *File1Path)
|
||||||
|
{
|
||||||
|
UINT32 Actual1;
|
||||||
|
|
||||||
|
|
||||||
|
File1 = fopen (File1Path, "rb");
|
||||||
|
if (!File1)
|
||||||
|
{
|
||||||
|
printf ("Could not open file %s\n", File1Path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Actual1 = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1);
|
||||||
|
if (Actual1 < sizeof (ACPI_TABLE_HEADER))
|
||||||
|
{
|
||||||
|
printf ("File %s does not contain an ACPI table header\n", File1Path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!AbValidateHeader (&Header1))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Display header information */
|
||||||
|
|
||||||
|
printf ("Signature : %8.4s\n", Header1.Signature);
|
||||||
|
printf ("Length : %8.8X\n", Header1.Length);
|
||||||
|
printf ("Revision : % 8.2X\n", Header1.Revision);
|
||||||
|
printf ("Checksum : % 8.2X\n", Header1.Checksum);
|
||||||
|
printf ("OEM ID : %8.6s\n", Header1.OemId);
|
||||||
|
printf ("OEM Table ID : %8.8s\n", Header1.OemTableId);
|
||||||
|
printf ("OEM Revision : %8.8X\n", Header1.OemRevision);
|
||||||
|
printf ("ASL Compiler ID : %8.4s\n", Header1.AslCompilerId);
|
||||||
|
printf ("Compiler Revision : %8.8X\n", Header1.AslCompilerRevision);
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AbComputeChecksum
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Compute proper checksum for an ACPI table
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
AbComputeChecksum (
|
||||||
|
char *File1Path)
|
||||||
|
{
|
||||||
|
UINT32 Actual1;
|
||||||
|
ACPI_TABLE_HEADER *Table;
|
||||||
|
UINT8 Checksum;
|
||||||
|
|
||||||
|
|
||||||
|
File1 = fopen (File1Path, "rb");
|
||||||
|
if (!File1)
|
||||||
|
{
|
||||||
|
printf ("Could not open file %s\n", File1Path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Actual1 = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1);
|
||||||
|
if (Actual1 < sizeof (ACPI_TABLE_HEADER))
|
||||||
|
{
|
||||||
|
printf ("File %s does not contain an ACPI table header\n", File1Path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!AbValidateHeader (&Header1))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Gbl_TerseMode)
|
||||||
|
{
|
||||||
|
/* Display header information */
|
||||||
|
|
||||||
|
printf ("Signature : %8.4s\n", Header1.Signature);
|
||||||
|
printf ("Length : %8.8X\n", Header1.Length);
|
||||||
|
printf ("Revision : % 8.2X\n", Header1.Revision);
|
||||||
|
printf ("Checksum : % 8.2X\n", Header1.Checksum);
|
||||||
|
printf ("OEM ID : %8.6s\n", Header1.OemId);
|
||||||
|
printf ("OEM Table ID : %8.8s\n", Header1.OemTableId);
|
||||||
|
printf ("OEM Revision : %8.8X\n", Header1.OemRevision);
|
||||||
|
printf ("ASL Compiler ID : %8.4s\n", Header1.AslCompilerId);
|
||||||
|
printf ("Compiler Revision : %8.8X\n", Header1.AslCompilerRevision);
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate a buffer to hold the entire table */
|
||||||
|
|
||||||
|
Table = AcpiOsAllocate (Header1.Length);
|
||||||
|
if (!Table)
|
||||||
|
{
|
||||||
|
printf ("could not allocate\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the entire table, including header */
|
||||||
|
|
||||||
|
fseek (File1, 0, SEEK_SET);
|
||||||
|
Actual1 = fread (Table, 1, Header1.Length, File1);
|
||||||
|
if (Actual1 < Header1.Length)
|
||||||
|
{
|
||||||
|
printf ("could not read table\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compute the checksum for the table */
|
||||||
|
|
||||||
|
Table->Checksum = 0;
|
||||||
|
|
||||||
|
Checksum = (UINT8) (0 - AcpiTbChecksum (Table, Table->Length));
|
||||||
|
printf ("Computed checksum: 0x%X\n\n", Checksum);
|
||||||
|
|
||||||
|
if (Header1.Checksum == Checksum)
|
||||||
|
{
|
||||||
|
printf ("Checksum ok in AML file, not updating\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open the target file for writing, to update checksum */
|
||||||
|
|
||||||
|
fclose (File1);
|
||||||
|
File1 = fopen (File1Path, "r+b");
|
||||||
|
if (!File1)
|
||||||
|
{
|
||||||
|
printf ("Could not open file %s for writing\n", File1Path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the checksum, write the new header */
|
||||||
|
|
||||||
|
Header1.Checksum = Checksum;
|
||||||
|
|
||||||
|
Actual1 = fwrite (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1);
|
||||||
|
if (Actual1 < sizeof (ACPI_TABLE_HEADER))
|
||||||
|
{
|
||||||
|
printf ("Could not write updated table header\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("Wrote new checksum\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* FUNCTION: AbCompareAmlFiles
|
* FUNCTION: AbCompareAmlFiles
|
||||||
@ -167,6 +453,7 @@ AbCompareAmlFiles (
|
|||||||
UINT8 Char1;
|
UINT8 Char1;
|
||||||
UINT8 Char2;
|
UINT8 Char2;
|
||||||
UINT8 Mismatches = 0;
|
UINT8 Mismatches = 0;
|
||||||
|
BOOLEAN HeaderMismatch = FALSE;
|
||||||
|
|
||||||
|
|
||||||
File1 = fopen (File1Path, "rb");
|
File1 = fopen (File1Path, "rb");
|
||||||
@ -176,7 +463,6 @@ AbCompareAmlFiles (
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
File2 = fopen (File2Path, "rb");
|
File2 = fopen (File2Path, "rb");
|
||||||
if (!File2)
|
if (!File2)
|
||||||
{
|
{
|
||||||
@ -184,7 +470,6 @@ AbCompareAmlFiles (
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Read the ACPI header from each file */
|
/* Read the ACPI header from each file */
|
||||||
|
|
||||||
Actual1 = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1);
|
Actual1 = fread (&Header1, 1, sizeof (ACPI_TABLE_HEADER), File1);
|
||||||
@ -209,13 +494,12 @@ AbCompareAmlFiles (
|
|||||||
|
|
||||||
/* Table signatures must match */
|
/* Table signatures must match */
|
||||||
|
|
||||||
if ((UINT32) Header1.Signature != (UINT32) Header1.Signature)
|
if (*((UINT32 *) Header1.Signature) != *((UINT32 *) Header2.Signature))
|
||||||
{
|
{
|
||||||
printf ("Table signatures do not match\n");
|
printf ("Table signatures do not match\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!Gbl_TerseMode)
|
if (!Gbl_TerseMode)
|
||||||
{
|
{
|
||||||
/* Display header information */
|
/* Display header information */
|
||||||
@ -232,6 +516,12 @@ AbCompareAmlFiles (
|
|||||||
printf ("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (memcmp (Header1.Signature, Header2.Signature, sizeof (ACPI_TABLE_HEADER)))
|
||||||
|
{
|
||||||
|
printf ("Headers do not match exactly\n");
|
||||||
|
HeaderMismatch = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Do the byte-by-byte compare */
|
/* Do the byte-by-byte compare */
|
||||||
|
|
||||||
Actual1 = fread (&Char1, 1, 1, File1);
|
Actual1 = fread (&Char1, 1, 1, File1);
|
||||||
@ -242,22 +532,21 @@ AbCompareAmlFiles (
|
|||||||
{
|
{
|
||||||
if (Char1 != Char2)
|
if (Char1 != Char2)
|
||||||
{
|
{
|
||||||
printf ("Error - Byte mismatch at offset %8.8X: 0x%2.2X 0x%2.2X\n", Offset, Char1, Char2);
|
printf ("Error - Byte mismatch at offset %8.8X: 0x%2.2X 0x%2.2X\n",
|
||||||
|
Offset, Char1, Char2);
|
||||||
Mismatches++;
|
Mismatches++;
|
||||||
if (Mismatches > 10)
|
if (Mismatches > 100)
|
||||||
{
|
{
|
||||||
printf ("10 Mismatches: Too many mismatches\n");
|
printf ("100 Mismatches: Too many mismatches\n");
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Offset++;
|
Offset++;
|
||||||
Actual1 = fread (&Char1, 1, 1, File1);
|
Actual1 = fread (&Char1, 1, 1, File1);
|
||||||
Actual2 = fread (&Char2, 1, 1, File2);
|
Actual2 = fread (&Char2, 1, 1, File2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Actual1)
|
if (Actual1)
|
||||||
{
|
{
|
||||||
printf ("Error - file %s is longer than file %s\n", File1Path, File2Path);
|
printf ("Error - file %s is longer than file %s\n", File1Path, File2Path);
|
||||||
@ -270,7 +559,14 @@ AbCompareAmlFiles (
|
|||||||
}
|
}
|
||||||
else if (!Mismatches)
|
else if (!Mismatches)
|
||||||
{
|
{
|
||||||
printf ("Files compare exactly after header\n");
|
if (HeaderMismatch)
|
||||||
|
{
|
||||||
|
printf ("Files compare exactly after header\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf ("Files compare exactly\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("%d Mismatches found\n", Mismatches);
|
printf ("%d Mismatches found\n", Mismatches);
|
||||||
@ -278,29 +574,25 @@ AbCompareAmlFiles (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct stat Gbl_StatBuf;
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* FUNCTION: AsGetFile
|
* FUNCTION: AsGetFile
|
||||||
*
|
*
|
||||||
* DESCRIPTION: Open a file and read it entirely into a an allocated buffer
|
* DESCRIPTION: Open a file and read it entirely into a new buffer
|
||||||
*
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
AbGetFile (
|
AbGetFile (
|
||||||
char *Filename,
|
char *Filename,
|
||||||
UINT32 *FileSize)
|
UINT32 *FileSize)
|
||||||
{
|
{
|
||||||
|
|
||||||
int FileHandle;
|
int FileHandle;
|
||||||
UINT32 Size;
|
UINT32 Size;
|
||||||
char *Buffer = NULL;
|
char *Buffer = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* Binary mode leaves CR/LF pairs */
|
/* Binary mode does not alter CR/LF pairs */
|
||||||
|
|
||||||
FileHandle = open (Filename, O_BINARY | O_RDONLY);
|
FileHandle = open (Filename, O_BINARY | O_RDONLY);
|
||||||
if (!FileHandle)
|
if (!FileHandle)
|
||||||
@ -309,22 +601,21 @@ AbGetFile (
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Need file size to allocate a buffer */
|
||||||
|
|
||||||
if (fstat (FileHandle, &Gbl_StatBuf))
|
if (fstat (FileHandle, &Gbl_StatBuf))
|
||||||
{
|
{
|
||||||
printf ("Could not get file status for %s\n", Filename);
|
printf ("Could not get file status for %s\n", Filename);
|
||||||
goto ErrorExit;
|
goto ErrorExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Allocate a buffer for the entire file */
|
||||||
* Create a buffer for the entire file
|
|
||||||
* Add 10% extra to accomodate string replacements
|
|
||||||
*/
|
|
||||||
|
|
||||||
Size = Gbl_StatBuf.st_size;
|
Size = Gbl_StatBuf.st_size;
|
||||||
Buffer = calloc (Size + (Size / 10), 1);
|
Buffer = calloc (Size, 1);
|
||||||
if (!Buffer)
|
if (!Buffer)
|
||||||
{
|
{
|
||||||
printf ("Could not allocate buffer of size %d\n", Size + (Size / 10));
|
printf ("Could not allocate buffer of size %d\n", Size);
|
||||||
goto ErrorExit;
|
goto ErrorExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,63 +639,218 @@ ErrorExit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AbDumpAmlFile
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Dump a binary AML file to a text file
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
AbDumpAmlFile (
|
AbDumpAmlFile (
|
||||||
char *File1Path)
|
char *File1Path,
|
||||||
|
char *File2Path)
|
||||||
{
|
{
|
||||||
char *FileBuffer;
|
char *FileBuffer;
|
||||||
UINT32 FileSize;
|
UINT32 FileSize;
|
||||||
|
FILE *FileOutHandle;
|
||||||
|
|
||||||
|
|
||||||
|
/* Get the entire AML file, validate header */
|
||||||
|
|
||||||
FileBuffer = AbGetFile (File1Path, &FileSize);
|
FileBuffer = AbGetFile (File1Path, &FileSize);
|
||||||
printf ("File %s contains 0x%X bytes\n\n", File1Path, FileSize);
|
printf ("File %s contains 0x%X bytes\n\n", File1Path, FileSize);
|
||||||
|
|
||||||
|
FileOutHandle = fopen (File2Path, "wb");
|
||||||
|
if (!FileOutHandle)
|
||||||
|
{
|
||||||
|
printf ("Could not open %s\n", File2Path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!AbValidateHeader ((ACPI_TABLE_HEADER *) FileBuffer))
|
if (!AbValidateHeader ((ACPI_TABLE_HEADER *) FileBuffer))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Convert binary AML to text, using common dump buffer routine */
|
||||||
|
|
||||||
|
AcpiGbl_DebugFile = FileOutHandle;
|
||||||
|
AcpiGbl_DbOutputFlags = ACPI_DB_REDIRECTABLE_OUTPUT;
|
||||||
|
|
||||||
|
AcpiOsPrintf ("%4.4s\n", ((ACPI_TABLE_HEADER *) FileBuffer)->Signature);
|
||||||
AcpiDbgLevel = ACPI_UINT32_MAX;
|
AcpiDbgLevel = ACPI_UINT32_MAX;
|
||||||
AcpiUtDumpBuffer (FileBuffer, FileSize, DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
|
AcpiUtDumpBuffer ((UINT8 *) FileBuffer, FileSize,
|
||||||
|
DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DB_CONSOLE_OUTPUT 0x02
|
|
||||||
|
|
||||||
FILE *AcpiGbl_DebugFile = NULL;
|
/******************************************************************************
|
||||||
UINT8 AcpiGbl_DbOutputFlags = DB_CONSOLE_OUTPUT ;
|
*
|
||||||
|
* FUNCTION: AbExtractAmlFile
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Extract a binary AML file from a text file (as produced by the
|
||||||
|
* DumpAmlFile procedure or the "acpidmp" table utility.
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
int
|
||||||
void *
|
AbExtractAmlFile (
|
||||||
AcpiUtCallocate (
|
char *TableSig,
|
||||||
UINT32 Size,
|
char *File1Path,
|
||||||
UINT32 Component,
|
char *File2Path)
|
||||||
NATIVE_CHAR *Module,
|
|
||||||
UINT32 Line)
|
|
||||||
{
|
{
|
||||||
|
char *Table;
|
||||||
|
char Value;
|
||||||
|
UINT32 i;
|
||||||
|
FILE *FileHandle;
|
||||||
|
FILE *FileOutHandle;
|
||||||
|
UINT32 Count = 0;
|
||||||
|
int Scanned;
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
/* Open in/out files. input is in text mode, output is in binary mode */
|
||||||
AcpiUtFree (
|
|
||||||
void *Address,
|
FileHandle = fopen (File1Path, "rt");
|
||||||
UINT32 Component,
|
if (!FileHandle)
|
||||||
NATIVE_CHAR *Module,
|
{
|
||||||
UINT32 Line)
|
printf ("Could not open %s\n", File1Path);
|
||||||
{
|
return -1;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
FileOutHandle = fopen (File2Path, "w+b");
|
||||||
|
if (!FileOutHandle)
|
||||||
|
{
|
||||||
|
printf ("Could not open %s\n", File2Path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Force input table sig to uppercase */
|
||||||
|
|
||||||
|
AcpiUtStrupr (TableSig);
|
||||||
|
|
||||||
|
|
||||||
|
/* TBD: examine input for ASCII */
|
||||||
|
|
||||||
|
|
||||||
|
/* We have an ascii file, grab one line at a time */
|
||||||
|
|
||||||
|
while (fgets (Buffer, BUFFER_SIZE, FileHandle))
|
||||||
|
{
|
||||||
|
/* The 4-char ACPI signature appears at the beginning of a line */
|
||||||
|
|
||||||
|
if (!strncmp (Buffer, TableSig, 4))
|
||||||
|
{
|
||||||
|
printf ("Found table [%4.4s]\n", TableSig);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Eat all lines in the table, of the form:
|
||||||
|
* <offset>: <16 bytes of hex data, separated by spaces> <ASCII representation> <newline>
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* 02C0: 5F 53 42 5F 4C 4E 4B 44 00 12 13 04 0C FF FF 08 _SB_LNKD........
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
while (fgets (Buffer, BUFFER_SIZE, FileHandle))
|
||||||
|
{
|
||||||
|
/* Get past the offset, terminated by a colon */
|
||||||
|
|
||||||
|
if (Count >= 0x3C50)
|
||||||
|
{
|
||||||
|
printf ("end\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
Table = strchr (Buffer, ':');
|
||||||
|
if (!Table)
|
||||||
|
{
|
||||||
|
/* No colon, all done */
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
Table += 2; /* Eat the colon + space */
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
Scanned = AbHexByteToBinary (Table, &Value);
|
||||||
|
if (!Scanned)
|
||||||
|
{
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
Table += 3; /* Go past this hex byte and space */
|
||||||
|
|
||||||
|
/* Write the converted (binary) byte */
|
||||||
|
|
||||||
|
fwrite (&Value, 1, 1, FileOutHandle);
|
||||||
|
Count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
Table += 2; /* Eat the colon + space */
|
||||||
|
|
||||||
|
/* Convert up to 16 bytes per input line */
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
/* Convert next integer from ASCII to binary, eats the space */
|
||||||
|
|
||||||
|
Value = strtoul (Table, &End, 16);
|
||||||
|
if (End == Table)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* No conversion was performed, all done. If other tables
|
||||||
|
* follow this one, this is where we will exit.
|
||||||
|
*/
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
Table += 3; /* Go past this hex byte and space */
|
||||||
|
|
||||||
|
/* Write the converted (binary) byte */
|
||||||
|
|
||||||
|
fwrite (&(char *) Value, 1, 1, FileOutHandle);
|
||||||
|
Count++;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No more lines, EOF, all done */
|
||||||
|
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Searched entire file, no match to table signature */
|
||||||
|
|
||||||
|
printf ("Could not match table signature\n");
|
||||||
|
fclose (FileHandle);
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
Exit:
|
||||||
|
printf ("%d (0x%X) bytes written to %s\n", Count, Count, File2Path);
|
||||||
|
fclose (FileHandle);
|
||||||
|
fclose (FileOutHandle);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *
|
/******************************************************************************
|
||||||
AcpiUtMemset (
|
*
|
||||||
void *Dest,
|
* FUNCTION: Stubs
|
||||||
UINT32 Value,
|
*
|
||||||
NATIVE_UINT Count)
|
* DESCRIPTION: For linkage
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
ACPI_STATUS
|
||||||
|
AeLocalGetRootPointer (
|
||||||
|
UINT32 Flags,
|
||||||
|
ACPI_PHYSICAL_ADDRESS *RsdpPhysicalAddress)
|
||||||
{
|
{
|
||||||
return (Dest);
|
return AE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user