16-bit support/fixes

date	2003.04.24.18.05.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 15:37:05 +00:00
parent 56c803be64
commit f2527faa0e
5 changed files with 664 additions and 299 deletions

View File

@ -138,6 +138,11 @@ FlatMove (
UINT32 Src,
UINT16 Size);
int ACPI_INTERNAL_VAR_XFACE
FlatMove32 (
UINT32 Dest,
UINT32 Src,
UINT16 Size);
ACPI_NATIVE_INT
AfWriteBuffer (
@ -151,9 +156,9 @@ AfGenerateFilename (char *TableId);
ACPI_STATUS
AfFindTable(
char *TableName,
UINT8 **TablePtr,
UINT32 *TableLength);
char *TableName,
UINT8 **TablePtr,
UINT32 *TableLength);
void
AfDumpTables (void);

View File

@ -2,7 +2,7 @@
*
* Module Name: a16find - 16-bit (real mode) routines to find ACPI
* tables in memory
* $Revision: 1.23 $
* $Revision: 1.24 $
*
*****************************************************************************/
@ -139,6 +139,9 @@
#if ACPI_MACHINE_WIDTH == 16
UINT32 ACPI_INTERNAL_VAR_XFACE dIn32 (UINT16 port);
void ACPI_INTERNAL_VAR_XFACE vOut32 (UINT16 port, UINT32 Val);
#define ACPI_ENABLE_HPET 0x00020000
char FilenameBuf[20];
ACPI_TABLE_HEADER AcpiTblHeader;
@ -246,6 +249,15 @@ AfDumpTables (void)
#endif
void pascal
cprint (
UINT32 value)
{
AcpiOsPrintf ("Seq: 0x%8.8X\n", value);
}
/******************************************************************************
*
* FUNCTION: CopyExtendedToReal
@ -267,7 +279,11 @@ CopyExtendedToReal (
int RetVal;
RetVal = FlatMove (GET_PHYSICAL_ADDRESS (Destination), PhysicalSource, (UINT16) Size);
RetVal = FlatMove32 (GET_PHYSICAL_ADDRESS (Destination),
PhysicalSource, (UINT16) Size);
AcpiOsPrintf ("FlatMove return: 0x%hX From %X To %X Len %X\n",
(int) RetVal, PhysicalSource, GET_PHYSICAL_ADDRESS (Destination), Size);
return (RetVal);
}
@ -594,9 +610,209 @@ AfGetAllTables (
}
ACPI_STATUS
AfGetRsdt (void)
{
BOOLEAN Found;
UINT32 PhysicalAddress;
UINT32 SignatureLength;
char *TableSignature;
ACPI_STATUS Status;
ACPI_TABLE_DESC TableInfo;
ACPI_FUNCTION_TRACE ("AfGetRsdt");
if (AcpiGbl_XSDT)
{
return (AE_OK);
}
Found = AfFindRsdp (&AcpiGbl_RSDP);
if (!Found)
{
AcpiOsPrintf ("Could not find RSDP in the low megabyte\n");
return (AE_NO_ACPI_TABLES);
}
/*
* For RSDP revision 0 or 1, we use the RSDT.
* For RSDP revision 2 (and above), we use the XSDT
*/
if (AcpiGbl_RSDP->Revision < 2)
{
PhysicalAddress = AcpiGbl_RSDP->RsdtPhysicalAddress;
TableSignature = RSDT_SIG;
SignatureLength = sizeof (RSDT_SIG) -1;
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found ACPI 1.0 RSDP\n"));
}
else
{
PhysicalAddress = ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress);
TableSignature = XSDT_SIG;
SignatureLength = sizeof (XSDT_SIG) -1;
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found ACPI 2.0 RSDP\n"));
}
if (AcpiGbl_DbOpt_verbose)
{
AcpiUtDumpBuffer ((char *) AcpiGbl_RSDP, sizeof (RSDP_DESCRIPTOR), 0, ACPI_UINT32_MAX);
}
/* Get the RSDT/XSDT header to determine the table length */
CopyExtendedToReal (&AcpiTblHeader, PhysicalAddress, sizeof (ACPI_TABLE_HEADER));
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDT/XSDT at %8.8X\n", (UINT32) PhysicalAddress));
if (AcpiGbl_DbOpt_verbose)
{
AcpiUtDumpBuffer ((char *) &AcpiTblHeader, sizeof (ACPI_TABLE_HEADER), 0, ACPI_UINT32_MAX);
}
/* Validate the table header */
Status = AcpiTbValidateTableHeader (&AcpiTblHeader);
if (ACPI_FAILURE (Status))
{
/* Table failed verification, map all errors to BAD_DATA */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid RSDT table header\n"));
return (AE_BAD_DATA);
}
/* Allocate a buffer for the entire table */
AcpiGbl_XSDT = (void *) malloc ((size_t) AcpiTblHeader.Length);
if (!AcpiGbl_XSDT)
{
AcpiOsPrintf ("Could not allocate buffer for RSDT length 0x%X\n",
(UINT32) AcpiTblHeader.Length);
return AE_NO_MEMORY;
}
/* Get the entire RSDT/XSDT */
CopyExtendedToReal (AcpiGbl_XSDT, PhysicalAddress, AcpiTblHeader.Length);
AcpiOsPrintf ("%s at %p (Phys %8.8X)\n",
TableSignature, AcpiGbl_XSDT, (UINT32) PhysicalAddress);
if (AcpiGbl_DbOpt_verbose)
{
AcpiUtDumpBuffer ((char *) &AcpiTblHeader, sizeof (ACPI_TABLE_HEADER), 0, 0);
}
/* Convert to common format XSDT */
TableInfo.Pointer = (ACPI_TABLE_HEADER *) AcpiGbl_XSDT;
TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length;
TableInfo.Allocation = ACPI_MEM_ALLOCATED;
AcpiGbl_RsdtTableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, TableInfo.Pointer);
Status = AcpiTbConvertToXsdt (&TableInfo);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
AcpiGbl_XSDT = (XSDT_DESCRIPTOR *) TableInfo.Pointer;
ErrorExit:
return (Status);
}
void
AfDumpRsdt (void)
{
UINT32 i;
UINT32 NumTables;
UINT32 PhysicalAddress;
ACPI_TABLE_HEADER **Table;
ACPI_TABLE_HEADER ThisTable;
NumTables = (AcpiGbl_XSDT->Header.Length - sizeof (ACPI_TABLE_HEADER)) / 8;
AcpiOsPrintf ("%d Tables defined in RSDT/XSDT:\n", NumTables);
for (i = 0; i < NumTables; i++)
{
PhysicalAddress = (UINT32) AcpiGbl_XSDT->TableOffsetEntry[i].Lo;
CopyExtendedToReal (&ThisTable, PhysicalAddress, sizeof (ACPI_TABLE_HEADER));
AcpiOsPrintf ("[%4.4s] ", ThisTable.Signature);
((char *) Table) += 8;
}
AcpiOsPrintf ("\n");
}
ACPI_STATUS
AfGetTable (
ACPI_TABLE_HEADER *TableHeader,
UINT32 PhysicalAddress,
UINT8 **TablePtr)
{
/* Allocate a buffer for the entire table */
*TablePtr = (void *) malloc ((size_t) TableHeader->Length);
if (!*TablePtr)
{
AcpiOsPrintf ("Could not allocate buffer for table length 0x%X\n",
(UINT32) TableHeader->Length);
return AE_NO_MEMORY;
}
/* Get the entire table */
CopyExtendedToReal (*TablePtr, PhysicalAddress, TableHeader->Length);
AcpiOsPrintf ("%4.4s at %p (Phys %8.8X)\n",
TableHeader->Signature, *TablePtr, (UINT32) PhysicalAddress);
if (AcpiGbl_DbOpt_verbose)
{
AcpiUtDumpBuffer ((char *) TableHeader, sizeof (ACPI_TABLE_HEADER), 0, 0);
}
return (AE_OK);
}
ACPI_STATUS
AfGetTableFromXsdt (
char *TableName,
UINT8 **TablePtr)
{
UINT32 i;
UINT32 NumTables;
UINT32 PhysicalAddress;
ACPI_TABLE_HEADER ThisTable;
NumTables = (AcpiGbl_XSDT->Header.Length - sizeof (ACPI_TABLE_HEADER)) / 8;
for (i = 0; i < NumTables; i++)
{
PhysicalAddress = (UINT32) AcpiGbl_XSDT->TableOffsetEntry[i].Lo;
CopyExtendedToReal (&ThisTable, PhysicalAddress, sizeof (ACPI_TABLE_HEADER));
if (!ACPI_STRNCMP (TableName, ThisTable.Signature, ACPI_NAME_SIZE))
{
AfGetTable (&ThisTable, PhysicalAddress, TablePtr);
return (AE_OK);
}
}
return (AE_NOT_FOUND);
}
/******************************************************************************
*
* FUNCTION: AfFindDsdt
* FUNCTION: AfFindTable
*
* PARAMETERS:
*
@ -607,115 +823,27 @@ AfGetAllTables (
*****************************************************************************/
ACPI_STATUS
AfFindTable(
AfFindTable (
char *TableName,
UINT8 **TablePtr,
UINT32 *TableLength)
{
ACPI_TABLE_DESC TableInfo;
BOOLEAN Found;
ACPI_STATUS Status;
UINT32 PhysicalAddress;
UINT32 SignatureLength;
char *TableSignature;
ACPI_FUNCTION_TRACE ("AfFindTable");
if (!AcpiGbl_RSDP)
if (!AcpiGbl_DSDT)
{
Found = AfFindRsdp (&AcpiGbl_RSDP);
if (!Found)
{
AcpiOsPrintf ("Could not find RSDP in the low megabyte\n");
return (AE_NO_ACPI_TABLES);
}
/*
* For RSDP revision 0 or 1, we use the RSDT.
* For RSDP revision 2 (and above), we use the XSDT
*/
if (AcpiGbl_RSDP->Revision < 2)
{
PhysicalAddress = AcpiGbl_RSDP->RsdtPhysicalAddress;
TableSignature = RSDT_SIG;
SignatureLength = sizeof (RSDT_SIG) -1;
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found ACPI 1.0 RSDP\n"));
}
else
{
PhysicalAddress = ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress);
TableSignature = XSDT_SIG;
SignatureLength = sizeof (XSDT_SIG) -1;
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Found ACPI 2.0 RSDP\n"));
}
if (AcpiGbl_DbOpt_verbose)
{
AcpiUtDumpBuffer ((char *) AcpiGbl_RSDP, sizeof (RSDP_DESCRIPTOR), 0, ACPI_UINT32_MAX);
}
/* Get the RSDT/XSDT header to determine the table length */
CopyExtendedToReal (&AcpiTblHeader, PhysicalAddress, sizeof (ACPI_TABLE_HEADER));
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDT/XSDT at %8.8X\n", (UINT32) PhysicalAddress));
if (AcpiGbl_DbOpt_verbose)
{
AcpiUtDumpBuffer ((char *) &AcpiTblHeader, sizeof (ACPI_TABLE_HEADER), 0, ACPI_UINT32_MAX);
}
/* Validate the table header */
Status = AcpiTbValidateTableHeader (&AcpiTblHeader);
Status = AfGetRsdt ();
if (ACPI_FAILURE (Status))
{
/* Table failed verification, map all errors to BAD_DATA */
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid RSDT table header\n"));
return (AE_BAD_DATA);
return (Status);
}
/* Allocate a buffer for the entire table */
AcpiGbl_XSDT = (void *) malloc ((size_t) AcpiTblHeader.Length);
if (!AcpiGbl_XSDT)
{
AcpiOsPrintf ("Could not allocate buffer for RSDT length 0x%X\n",
(UINT32) AcpiTblHeader.Length);
return AE_NO_MEMORY;
}
/* Get the entire RSDT/XSDT */
CopyExtendedToReal (AcpiGbl_XSDT, PhysicalAddress, AcpiTblHeader.Length);
AcpiOsPrintf ("%s at %p (Phys %8.8X)\n",
TableSignature, AcpiGbl_XSDT, (UINT32) PhysicalAddress);
if (AcpiGbl_DbOpt_verbose)
{
AcpiUtDumpBuffer ((char *) &AcpiTblHeader, sizeof (ACPI_TABLE_HEADER), 0, 0);
}
/* Convert to common format XSDT */
TableInfo.Pointer = (ACPI_TABLE_HEADER *) AcpiGbl_XSDT;
TableInfo.Length = (ACPI_SIZE) AcpiTblHeader.Length;
TableInfo.Allocation = ACPI_MEM_ALLOCATED;
AcpiGbl_RsdtTableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, TableInfo.Pointer);
Status = AcpiTbConvertToXsdt (&TableInfo);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
AcpiGbl_XSDT = (XSDT_DESCRIPTOR *) TableInfo.Pointer;
AfDumpRsdt ();
/* Get the rest of the required tables (DSDT, FADT) */
Status = AfGetAllTables (AcpiGbl_RsdtTableCount, NULL);
@ -748,12 +876,22 @@ AfFindTable(
*TablePtr = (UINT8 *) AcpiGbl_XSDT;
*TableLength = AcpiGbl_XSDT->Header.Length;
}
else
else if (!ACPI_STRNCMP (TableName, SSDT_SIG, ACPI_NAME_SIZE))
{
AcpiOsPrintf ("Unsupported table signature: [%4.4s]\n", TableName);
*TablePtr = NULL;
return AE_SUPPORT;
}
else
{
Status = AfGetTableFromXsdt (TableName, TablePtr);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
*TableLength = (*((ACPI_TABLE_HEADER **)TablePtr))->Length;
}
return AE_OK;
@ -764,5 +902,56 @@ ErrorExit:
return (Status);
}
#ifdef _HPET
UINT8 Hbuf[1024];
void
AfGetHpet (void)
{
HPET_DESCRIPTION_TABLE *NewTable;
ACPI_TABLE_HEADER TableHeader;
ACPI_STATUS Status;
UINT16 i;
UINT32 Value;
UINT32 Value2;
/* Get HPET TEMP! */
ACPI_STRNCPY (TableHeader.Signature, "HPET", 4);
Status = AcpiOsTableOverride (&TableHeader, (ACPI_TABLE_HEADER **) &NewTable);
if (ACPI_FAILURE (Status))
{
return;
}
AcpiDbgLevel |= ACPI_LV_TABLES;
AcpiOsPrintf ("HPET table :\n");
AcpiUtDumpBuffer ((char *) NewTable, NewTable->Header.Length, DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
for (i = 0; i < 1024; i++)
{
Hbuf[i] = (UINT8) i;
}
/* enable HPET */
CopyExtendedToReal (&Value, 0xD0, 4);
AcpiOsPrintf ("Reg 0xD0: %8.8X\n", Value);
Value = dIn32 (0xD0);
AcpiOsPrintf ("Port 0xD0: %8.8X\n", Value);
Value |= ACPI_ENABLE_HPET;
vOut32 (0xD0, Value);
Value2 = dIn32 (0xD0);
AcpiOsPrintf ("Port 0xD0: Wrote: %8.8X got %8.8X\n", Value, Value2);
AcpiOsPrintf ("HPET block(at %8.8X):\n", NewTable->BaseAddress[2]);
CopyExtendedToReal (Hbuf, NewTable->BaseAddress[2], 1024);
AcpiUtDumpBuffer ((char *) Hbuf, 1024, DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
}
#endif /* _HPET */
#endif /* IA16 */

View File

@ -11,7 +11,9 @@ TITLE BU_ASM.ASM -- ASM support for DOS BU_LIB
;* magnetic, optical, chemical, manual, or otherwise, without
;* the prior written permission of Intel Corporation.
;****************************************************************************
; BU_ASM.ASM -- ASM support for DOS BU_LIB
;
; To assemble with MASM61 -- ml /c a16utils.asm
;
;****************************************************************************
.286
@ -82,6 +84,8 @@ PUBLIC _dAPAwake, _dAPDone, _dAPFuncPtr, _wProcNumber, _bSPValid
PUBLIC _wCSegDS, _wCSegES, _wCSegSS, _wCSegSP, _wASegDS, _wASegES
PUBLIC _dAPHltJmp
emsfilename DB 'EMMXXXX0',0
_dAPAwake DD 0
@ -110,11 +114,14 @@ PUBLIC _dAPHltJmp
; 4G flat data segment
DD 0ffffh ; base 0, limit 0xfffff
DD 008f9200h ; data, CPL=0, 16-bit, 4K granularity, r/w
_old_es DW 0
_old_ds DW 0
_old_fs DW 0
_old_gs DW 0
_dAPHltJmp DD 0 ; jump to halt location
.CODE
EXTERNDEF pascal cprint:proc
PUBLIC ems_present
ems_present PROC C
@ -448,8 +455,116 @@ vFlatFsGs PROC C
ret
vFlatFsGs ENDP
PUBLIC vRealEsDs
vRealEsDs PROC C
; TBD: verify this on an AMD K6-2 266 MHz
; Assert A20M# via system control port A (This is a
; system dependent feature).
in al, 92h
and al, 0fdh
out 92h, al ; re-assert A20M#
GOPROT
mov ax, 8
mov gs, ax
GOREAL
mov ax, [_old_es] ; restore original
mov es, ax
mov ax, [_old_gs] ; restore original
mov gs, ax
sti
ret
vRealEsDs ENDP
;--------------------------------------------------------------------
PUBLIC vFlatEsDs
vFlatEsDs PROC C
cli
mov ax, es
mov [_old_es], ax ; save original
mov ax, gs
mov [_old_gs], ax ; save original
; Deassert A20M# via system control port A (This is a
; system dependent feature)
in al, 92h
or al, 2
out 92h, al ; de-assert A20M#
GOPROT
mov ax, 10h
mov es, ax
mov gs, ax
GOREAL
ret
vFlatEsDs ENDP
PUBLIC print
print PROC PASCAL Seq:DWORD
pushad
mov eax, Seq
push eax
call cprint
popad
ret
print ENDP
PUBLIC DoMove
DoMove PROC
push edx
; GOPROT
pop edx
mov ecx, edx
shr ecx, 2 ; byte count / 4 = dword count
cmp ecx, 0
je DoBytes
NextDword:
xor eax, eax
lock or eax, gs:[esi]
; mov eax, gs:[esi]
mov gs:[edi], eax
add esi, 4
add edi, 4
loop NextDword
DoBytes:
mov ecx, edx
and ecx, 3
cmp ecx, 0
je Exit ; no extra bytes to move
NextByte:
mov al, byte ptr gs:[esi]
mov byte ptr gs:[edi], al
inc esi
inc edi
loop NextByte
Exit:
; GOREAL
ret
DoMove ENDP
.586
;--------------------------------------------------------------------
PUBLIC _WriteApic
@ -645,38 +760,156 @@ vOut32 ENDP
;--------------------------------------------------------------------
; int FlatMove (DWORD dPhysicalDestination, DWORD dPhysicalSource, size_t sSize)
PUBLIC FlatMove
FlatMove PROC C dDest:DWORD, dSrc:DWORD, sSize:WORD
call vm86 ; check if VM86 mode
cmp ax, 0
jne NotRealMode ; skip memory move if not in real mode
call vFlatFsGs ; set up FS and GS as 4GB limit selectors with
; base 0:0 and de-assert A20M#
PUBLIC FlatMoveX
FlatMoveX PROC C dDest:DWORD, dSrc:DWORD, sSize:WORD
call vm86 ; check if VM86 mode
cmp ax, 0
jne NotRealMode ; skip memory move if not in real mode
call vFlatFsGs ; set up FS and GS as 4GB limit selectors with
; base 0:0 and de-assert A20M#
movzx ecx, sSize
cmp ecx, 0
je SKipMemoryMove ; skip memory move if 0==sSize
cmp ecx, 0
je SKipMemoryMove ; skip memory move if 0==sSize
mov eax, dDest
cmp eax, 400h
jbe SkipMemoryMove ; skip memory move if destination is 40:0
; BIOS Data Area or less (IVT)
mov eax, dDest
cmp eax, 400h
jbe SkipMemoryMove ; skip memory move if destination is 40:0
; BIOS Data Area or less (IVT)
mov ebx, dSrc
mov ebx, dSrc
NextByte:
mov dl, gs:[ebx][ecx - 1]
mov gs:[eax][ecx - 1], dl
mov dl, gs:[ebx][ecx - 1]
mov gs:[eax][ecx - 1], dl
loop NextByte
call vRealFsGs
xor ax, ax
xor ax, ax
NotRealMode:
ret
SkipMemoryMove:
mov ax, 1 ; return error code
mov ax, 1 ; return error code
ret
FlatMove ENDP
FlatMoveX ENDP
; int FlatMove32 (DWORD dPhysicalDestination, DWORD dPhysicalSource, size_t sSize)
PUBLIC FlatMove32
FlatMove32 PROC C dDest:DWORD, dSrc:DWORD, sSize:WORD
call vm86 ; check if VM86 mode
cmp ax, 0
jne NotRealMode ; skip memory move if not in real mode
call vFlatFsGs ; set up FS and GS as 4GB limit selectors with
; base 0:0 and de-assert A20M#
movzx edx, sSize
mov esi, dSrc
mov edi, dDest
push edx
call print
push esi
call print
push edi
call print
cmp edx, 0
je SkipMemoryMove ; skip memory move if 0==sSize
cmp edi, 400h
jbe SkipMemoryMove ; skip memory move if destination is 40:0
; BIOS Data Area or less (IVT)
call DoMove ; edx=Count, esi=src, edi=dst
movzx ecx, sSize
shr ecx, 2
mov edi, dDest
PrintLoop:
mov eax, gs:[edi]
push eax
call print
add edi, 4
loop PrintLoop
call vRealFsGs
xor ax, ax
NotRealMode:
ret
SkipMemoryMove:
call print
call vRealEsDs
mov ax, 1 ; return error code
ret
FlatMove32 ENDP
; int FlatMove32 (DWORD dPhysicalDestination, DWORD dPhysicalSource, size_t sSize)
PUBLIC FlatMove32x
FlatMove32x PROC C dDest:DWORD, dSrc:DWORD, sSize:WORD
call vm86 ; check if VM86 mode
cmp ax, 0
jne NotRealMode ; skip memory move if not in real mode
call vFlatFsGs ; set up FS and GS as 4GB limit selectors with
; base 0:0 and de-assert A20M#
movzx ecx, sSize
cmp ecx, 0
je SKipMemoryMove ; skip memory move if 0==sSize
mov eax, dDest
cmp eax, 400h
jbe SkipMemoryMove ; skip memory move if destination is 40:0
; BIOS Data Area or less (IVT)
mov ebx, dSrc
mov esi, 0
push ecx
call print
push ebx
call print
push eax
call print
shr ecx, 2 ; byte count / 4 = dword count
cmp ecx, 0
je DoBytes
NextDword:
mov edx, dword ptr gs:[ebx][esi]
mov dword ptr gs:[eax][esi], edx
push edx
call print
add esi, 4
loop NextDword
DoBytes:
movzx ecx, sSize
and ecx, 3
cmp ecx, 0
je Exit ; no extra bytes to move
NextByte:
mov dl, gs:[ebx][esi]
mov gs:[eax][esi], dl
inc esi
loop NextByte
Exit:
call vRealFsGs
xor ax, ax
NotRealMode:
ret
SkipMemoryMove:
mov ax, 1 ; return error code
ret
FlatMove32x ENDP
END

Binary file not shown.

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: adisasm - Application-level disassembler routines
* $Revision: 1.54 $
* $Revision: 1.57 $
*
*****************************************************************************/
@ -134,11 +134,7 @@
ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot;
ACPI_PARSE_OBJECT *root;
UINT8 *AmlStart;
UINT32 AmlLength;
UINT8 *DsdtPtr;
UINT32 DsdtLength;
#ifndef _ACPI_ASL_COMPILER
BOOLEAN
@ -287,8 +283,7 @@ AdWriteTable (
Filename = AdGenerateFilename (TableName, OemTableId);
AdWriteBuffer (Filename,
(char *) Table, Length);
AdWriteBuffer (Filename, (char *) Table, Length);
AcpiOsPrintf ("Table [%s] written to \"%s\"\n", TableName, Filename);
}
@ -477,15 +472,16 @@ AdAmlDisassemble (
ACPI_STATUS Status;
char *DisasmFilename = NULL;
FILE *File = NULL;
ACPI_TABLE_HEADER *Table;
/*
* AML Input:
* Either from a file, or via GetTables (memory or registry)
* Input: AML Code from either a file,
* or via GetTables (memory or registry)
*/
if (Filename)
{
Status = AcpiDbLoadAcpiTable (Filename);
Status = AcpiDbGetTableFromFile (Filename, &Table);
if (ACPI_FAILURE (Status))
{
return Status;
@ -493,7 +489,7 @@ AdAmlDisassemble (
}
else
{
Status = AdGetTables (Filename, GetAllTables);
Status = AdGetLocalTables (Filename, GetAllTables);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not get ACPI tables, %s\n",
@ -506,13 +502,16 @@ AdAmlDisassemble (
return AE_OK;
}
/* Obtained the local tables, just disassmeble the DSDT */
Table = AcpiGbl_DSDT;
AcpiOsPrintf ("\nDisassembly of DSDT\n");
Prefix = AdGenerateFilename ("dsdt", AcpiGbl_DSDT->OemTableId);
}
/*
* ASL Output:
* Redirect to a file if requested
* Output: ASL code.
* Redirect to a file if requested
*/
if (OutToFile)
{
@ -537,7 +536,7 @@ AdAmlDisassemble (
/* Always parse the tables, only option is what to display */
Status = AdParseTables ();
Status = AdParseTable (Table);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
@ -549,7 +548,7 @@ AdAmlDisassemble (
if (AcpiGbl_DbOpt_disasm)
{
AdDisplayTables (Filename);
AdDisplayTables (Filename, Table);
fprintf (stderr, "Disassembly completed, written to \"%s\"\n", DisasmFilename);
}
@ -586,6 +585,7 @@ AdCreateTableHeader (
{
time_t Timer;
time (&Timer);
AcpiOsPrintf ("/*\n * Intel ACPI Component Architecture\n");
@ -593,8 +593,8 @@ AdCreateTableHeader (
AcpiOsPrintf (" *\n * Disassembly of %s, %s */\n", Filename, ctime (&Timer));
AcpiOsPrintf (
"DefinitionBlock (\"DSDT.aml\", \"%4.4s\", %hd, \"%.6s\", \"%.8s\", %d)\n",
Table->Signature, Table->Revision,
"DefinitionBlock (\"%4.4s.aml\", \"%4.4s\", %hd, \"%.6s\", \"%.8s\", %d)\n",
Table->Signature, Table->Signature, Table->Revision,
Table->OemId, Table->OemTableId, Table->OemRevision);
}
@ -613,31 +613,31 @@ AdCreateTableHeader (
ACPI_STATUS
AdDisplayTables (
char *Filename)
char *Filename,
ACPI_TABLE_HEADER *Table)
{
if (!AcpiGbl_DSDT || !AcpiGbl_ParsedNamespaceRoot)
if (!AcpiGbl_ParsedNamespaceRoot)
{
return AE_NOT_EXIST;
}
if (!AcpiGbl_DbOpt_verbose)
{
AdCreateTableHeader (Filename, AcpiGbl_DSDT);
AdCreateTableHeader (Filename, Table);
}
AcpiDmDisassemble (NULL, AcpiGbl_ParsedNamespaceRoot, ACPI_UINT32_MAX);
if (AcpiGbl_DbOpt_verbose)
{
AcpiOsPrintf ("\n\nDSDT Header:\n");
AcpiUtDumpBuffer ((UINT8 *) AcpiGbl_DSDT, sizeof (ACPI_TABLE_HEADER),
AcpiOsPrintf ("\n\nTable Header:\n");
AcpiUtDumpBuffer ((UINT8 *) Table, sizeof (ACPI_TABLE_HEADER),
DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
AcpiOsPrintf ("DSDT Body (Length 0x%X)\n", AmlLength);
AcpiUtDumpBuffer ((UINT8 *) AmlStart, AmlLength,
AcpiOsPrintf ("Table Body (Length 0x%X)\n", Table->Length);
AcpiUtDumpBuffer (((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)), Table->Length,
DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
}
@ -645,64 +645,6 @@ AdDisplayTables (
}
/******************************************************************************
*
* FUNCTION: AdLoadDsdt
*
* PARAMETERS: fp - Input file
* seekable - can seek on the input file?
* DsdtPtr - Where pointer to the dsdt is returned
* DsdtLength - Where dsdt length is returned
*
* RETURN: Status
*
* DESCRIPTION: Load the DSDT from the file pointer
*
*****************************************************************************/
ACPI_STATUS
AdLoadDsdt (
FILE *fp,
int seekable,
UINT8 **DsdtPtr,
UINT32 *DsdtLength)
{
ACPI_TABLE_HEADER dsdt_hdr;
UINT8 *AmlStart;
UINT32 AmlLength;
if (fread(&dsdt_hdr, 1, sizeof (dsdt_hdr), fp) == sizeof (dsdt_hdr))
{
*DsdtLength = dsdt_hdr.Length;
if (*DsdtLength)
{
*DsdtPtr = (UINT8*) malloc ((size_t) *DsdtLength);
if (*DsdtPtr)
{
AmlStart = *DsdtPtr + sizeof (dsdt_hdr);
AmlLength = *DsdtLength - sizeof (dsdt_hdr);
memcpy (*DsdtPtr, &dsdt_hdr, sizeof (dsdt_hdr));
if ((UINT32) fread (AmlStart, 1, (size_t) AmlLength, fp) == AmlLength)
{
return AE_OK;
}
free(*DsdtPtr);
}
}
}
*DsdtPtr = NULL;
*DsdtLength = 0;
return AE_NO_ACPI_TABLES;
}
/******************************************************************************
*
* FUNCTION: AdDeferredParse
@ -758,7 +700,6 @@ AdDeferredParse (
return_ACPI_STATUS (Status);
}
/* Parse the method */
WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
@ -904,9 +845,9 @@ AdParseDeferredOps (
/******************************************************************************
*
* FUNCTION: AdGetTables
* FUNCTION: AdGetLocalTables
*
* PARAMETERS: Filename - Optional filename
* PARAMETERS:
*
* RETURN: None
*
@ -915,11 +856,10 @@ AdParseDeferredOps (
*****************************************************************************/
ACPI_STATUS
AdGetTables (
AdGetLocalTables (
char *Filename,
BOOLEAN GetAllTables)
{
FILE *fp;
ACPI_STATUS Status;
ACPI_TABLE_HEADER TableHeader;
ACPI_TABLE_HEADER *NewTable;
@ -927,102 +867,99 @@ AdGetTables (
UINT32 PointerSize;
if (Filename)
if (GetAllTables)
{
fprintf (stderr, "Loading DSDT from file %s\n", Filename);
fp = fopen (Filename, "rb");
if (!fp)
{
printf ("Couldn't open %s\n", Filename);
return AE_ERROR;
}
Status = AdLoadDsdt (fp, (fp != stdin), &DsdtPtr, &DsdtLength);
if (fp != stdin)
{
fclose(fp);
}
}
else
{
if (GetAllTables)
{
ACPI_STRNCPY (TableHeader.Signature, "RSDT", 4);
AcpiOsTableOverride (&TableHeader, &NewTable);
ACPI_STRNCPY (TableHeader.Signature, "RSDT", 4);
AcpiOsTableOverride (&TableHeader, &NewTable);
#if ACPI_MACHINE_WIDTH != 64
if (!ACPI_STRNCMP (NewTable->Signature, "RSDT", 4))
{
PointerSize = sizeof (UINT32);
}
else
if (!ACPI_STRNCMP (NewTable->Signature, "RSDT", 4))
{
PointerSize = sizeof (UINT32);
}
else
#endif
{
PointerSize = sizeof (UINT64);
}
/*
* Determine the number of tables pointed to by the RSDT/XSDT.
* This is defined by the ACPI Specification to be the number of
* pointers contained within the RSDT/XSDT. The size of the pointers
* is architecture-dependent.
*/
NumTables = (NewTable->Length - sizeof (ACPI_TABLE_HEADER)) / PointerSize;
AcpiOsPrintf ("There are %d tables defined in the %4.4s\n\n",
NumTables, NewTable->Signature);
/* Get the FADT */
ACPI_STRNCPY (TableHeader.Signature, "FADT", 4);
AcpiOsTableOverride (&TableHeader, &NewTable);
if (NewTable)
{
AcpiGbl_FADT = (void *) NewTable;
AdWriteTable (NewTable, NewTable->Length,
"FADT", NewTable->OemTableId);
}
AcpiOsPrintf ("\n");
/* Get the FACS */
ACPI_STRNCPY (TableHeader.Signature, "FACS", 4);
AcpiOsTableOverride (&TableHeader, &NewTable);
if (NewTable)
{
AcpiGbl_FACS = (void *) NewTable;
AdWriteTable (NewTable, AcpiGbl_FACS->Length,
"FACS", AcpiGbl_FADT->Header.OemTableId);
}
AcpiOsPrintf ("\n");
{
PointerSize = sizeof (UINT64);
}
/* Always get the DSDT */
/*
* Determine the number of tables pointed to by the RSDT/XSDT.
* This is defined by the ACPI Specification to be the number of
* pointers contained within the RSDT/XSDT. The size of the pointers
* is architecture-dependent.
*/
NumTables = (NewTable->Length - sizeof (ACPI_TABLE_HEADER)) / PointerSize;
AcpiOsPrintf ("There are %d tables defined in the %4.4s\n\n",
NumTables, NewTable->Signature);
ACPI_STRNCPY (TableHeader.Signature, DSDT_SIG, 4);
/* Get the FADT */
ACPI_STRNCPY (TableHeader.Signature, "FADT", 4);
AcpiOsTableOverride (&TableHeader, &NewTable);
if (NewTable)
{
Status = AE_OK;
AcpiGbl_DSDT = NewTable;
DsdtPtr = (UINT8 *) AcpiGbl_DSDT;
DsdtLength = AcpiGbl_DSDT->Length;
AdWriteTable (AcpiGbl_DSDT, AcpiGbl_DSDT->Length,
"DSDT", AcpiGbl_DSDT->OemTableId);
AcpiGbl_FADT = (void *) NewTable;
AdWriteTable (NewTable, NewTable->Length,
"FADT", NewTable->OemTableId);
}
else
AcpiOsPrintf ("\n");
/* Get the FACS */
ACPI_STRNCPY (TableHeader.Signature, "FACS", 4);
AcpiOsTableOverride (&TableHeader, &NewTable);
if (NewTable)
{
fprintf (stderr, "Could not obtain DSDT\n");
Status = AE_NO_ACPI_TABLES;
AcpiGbl_FACS = (void *) NewTable;
AdWriteTable (NewTable, AcpiGbl_FACS->Length,
"FACS", AcpiGbl_FADT->Header.OemTableId);
}
AcpiOsPrintf ("\n");
}
/* Always get the DSDT */
ACPI_STRNCPY (TableHeader.Signature, DSDT_SIG, 4);
AcpiOsTableOverride (&TableHeader, &NewTable);
if (NewTable)
{
Status = AE_OK;
AcpiGbl_DSDT = NewTable;
AdWriteTable (AcpiGbl_DSDT, AcpiGbl_DSDT->Length,
"DSDT", AcpiGbl_DSDT->OemTableId);
}
else
{
fprintf (stderr, "Could not obtain DSDT\n");
Status = AE_NO_ACPI_TABLES;
}
AcpiOsPrintf ("\n");
/* Get all SSDTs */
ACPI_STRNCPY (TableHeader.Signature, SSDT_SIG, 4);
Status = AcpiOsTableOverride (&TableHeader, &NewTable);
if (NewTable)
{
while (NewTable)
{
Status = AcpiOsTableOverride (&TableHeader, &NewTable);
}
}
return Status;
#ifdef _HPET
AfGetHpet ();
#endif
return AE_OK;
}
/******************************************************************************
*
* FUNCTION: AdParseTables
* FUNCTION: AdParseTable
*
* PARAMETERS: None
*
@ -1033,26 +970,27 @@ AdGetTables (
*****************************************************************************/
ACPI_STATUS
AdParseTables (
void)
AdParseTable (
ACPI_TABLE_HEADER *Table)
{
ACPI_STATUS Status = AE_OK;
ACPI_WALK_STATE *WalkState;
ACPI_TABLE_DESC TableDesc;
UINT8 *AmlStart;
UINT32 AmlLength;
if (!AcpiGbl_DSDT)
if (!Table)
{
return AE_NOT_EXIST;
}
/* Pass 1: Parse everything except control method bodies */
fprintf (stderr, "Pass 1 parse\n");
fprintf (stderr, "Pass 1 parse of [%4.4s]\n", (char *) Table->Signature);
DsdtLength = AcpiGbl_DSDT->Length;
AmlLength = DsdtLength - sizeof (ACPI_TABLE_HEADER);
AmlStart = ((UINT8 *) AcpiGbl_DSDT + sizeof (ACPI_TABLE_HEADER));
AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER));
/* Create the root object */
@ -1065,14 +1003,14 @@ AdParseTables (
/* Create and initialize a new walk state */
WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT,
AcpiGbl_ParsedNamespaceRoot, NULL, NULL);
AcpiGbl_ParsedNamespaceRoot, NULL, NULL);
if (!WalkState)
{
return (AE_NO_MEMORY);
}
Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParsedNamespaceRoot, NULL, AmlStart,
AmlLength, NULL, NULL, 1);
Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParsedNamespaceRoot,
NULL, AmlStart, AmlLength, NULL, NULL, 1);
if (ACPI_FAILURE (Status))
{
return (Status);
@ -1090,7 +1028,7 @@ AdParseTables (
TableDesc.AmlStart = AmlStart;
TableDesc.AmlLength = AmlLength;
fprintf (stderr, "Pass 2 parse\n");
fprintf (stderr, "Pass 2 parse of [%4.4s]\n", (char *) Table->Signature);
Status = AcpiNsOneCompleteParse (2, &TableDesc);
if (ACPI_FAILURE (Status))