summaryrefslogtreecommitdiff
path: root/source/os_specific
diff options
context:
space:
mode:
Diffstat (limited to 'source/os_specific')
-rw-r--r--source/os_specific/service_layers/oslinuxtbl.c137
-rw-r--r--source/os_specific/service_layers/osunixxf.c17
-rw-r--r--source/os_specific/service_layers/oswindir.c1
-rw-r--r--source/os_specific/service_layers/oswintbl.c259
-rw-r--r--source/os_specific/service_layers/oswinxf.c27
5 files changed, 361 insertions, 80 deletions
diff --git a/source/os_specific/service_layers/oslinuxtbl.c b/source/os_specific/service_layers/oslinuxtbl.c
new file mode 100644
index 0000000000000..2d1be3fb66fc8
--- /dev/null
+++ b/source/os_specific/service_layers/oslinuxtbl.c
@@ -0,0 +1,137 @@
+/******************************************************************************
+ *
+ * Module Name: oslinuxtbl - Linux OSL for obtaining ACPI tables
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2013, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include "acpi.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define _COMPONENT ACPI_OS_SERVICES
+ ACPI_MODULE_NAME ("oslinuxtbl")
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsGetTableByAddress
+ *
+ * PARAMETERS: Address - Physical address of the ACPI table
+ * Table - Where a pointer to the table is returned
+ *
+ * RETURN: Status; Table buffer is returned if AE_OK.
+ * AE_NOT_FOUND: A valid table was not found at the address
+ *
+ * DESCRIPTION: Get an ACPI table via a physical memory address.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsGetTableByAddress (
+ ACPI_PHYSICAL_ADDRESS Address,
+ ACPI_TABLE_HEADER **Table)
+{
+
+ fprintf (stderr, "Linux version not implemented yet\n");
+ return (AE_SUPPORT);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsGetTableByIndex
+ *
+ * PARAMETERS: Index - Which table to get
+ * Table - Where a pointer to the table is returned
+ * Address - Where the table physical address is returned
+ *
+ * RETURN: Status; Table buffer and physical address returned if AE_OK.
+ * AE_LIMIT: Index is beyond valid limit
+ *
+ * DESCRIPTION: Get an ACPI table via an index value (0 through n). Returns
+ * AE_LIMIT when an invalid index is reached. Index is not
+ * necessarily an index into the RSDT/XSDT.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsGetTableByIndex (
+ UINT32 Index,
+ ACPI_TABLE_HEADER **Table,
+ ACPI_PHYSICAL_ADDRESS *Address)
+{
+
+ fprintf (stderr, "Linux version not implemented yet\n");
+ return (AE_SUPPORT);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsGetTableByName
+ *
+ * PARAMETERS: Signature - ACPI Signature for desired table. Must be
+ * a null terminated 4-character string.
+ * Instance - For SSDTs (0...n)
+ * Table - Where a pointer to the table is returned
+ * Address - Where the table physical address is returned
+ *
+ * RETURN: Status; Table buffer and physical address returned if AE_OK.
+ *
+ * RETURN: Status; Table buffer and physical address returned if AE_OK.
+ * AE_LIMIT: Instance is beyond valid limit
+ * AE_NOT_FOUND: A table with the signature was not found
+ *
+ * NOTE: Assumes the input signature is uppercase.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsGetTableByName (
+ char *Signature,
+ UINT32 Instance,
+ ACPI_TABLE_HEADER **Table,
+ ACPI_PHYSICAL_ADDRESS *Address)
+{
+
+ fprintf (stderr, "Linux version not implemented yet\n");
+ return (AE_SUPPORT);
+}
diff --git a/source/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c
index 2afc54e9df13d..f77d70e97896d 100644
--- a/source/os_specific/service_layers/osunixxf.c
+++ b/source/os_specific/service_layers/osunixxf.c
@@ -45,8 +45,6 @@
/*
* These interfaces are required in order to compile the ASL compiler and the
* various ACPICA tools under Linux or other Unix-like system.
- *
- * Note: Use #define __APPLE__ for OS X generation.
*/
#include "acpi.h"
#include "accommon.h"
@@ -88,12 +86,6 @@ typedef void* (*PTHREAD_CALLBACK) (void *);
#define ACPI_VPRINTF_BUFFER_SIZE 512
-/* Apple-specific */
-
-#ifdef __APPLE__
-#define sem_destroy sem_close
-#endif
-
/******************************************************************************
*
@@ -1086,18 +1078,22 @@ AcpiOsReadPort (
switch (Width)
{
case 8:
+
*Value = 0xFF;
break;
case 16:
+
*Value = 0xFFFF;
break;
case 32:
+
*Value = 0xFFFFFFFF;
break;
default:
+
return (AE_BAD_PARAMETER);
}
@@ -1158,10 +1154,12 @@ AcpiOsReadMemory (
case 16:
case 32:
case 64:
+
*Value = 0;
break;
default:
+
return (AE_BAD_PARAMETER);
}
return (AE_OK);
@@ -1261,12 +1259,15 @@ AcpiOsSignal (
switch (Function)
{
case ACPI_SIGNAL_FATAL:
+
break;
case ACPI_SIGNAL_BREAKPOINT:
+
break;
default:
+
break;
}
diff --git a/source/os_specific/service_layers/oswindir.c b/source/os_specific/service_layers/oswindir.c
index d7ead1c4474a2..dc8916a5be31f 100644
--- a/source/os_specific/service_layers/oswindir.c
+++ b/source/os_specific/service_layers/oswindir.c
@@ -214,6 +214,7 @@ AcpiOsGetNextFilename (
break;
default:
+
return (NULL);
}
}
diff --git a/source/os_specific/service_layers/oswintbl.c b/source/os_specific/service_layers/oswintbl.c
index 6dcd5546b88a6..347927f826b01 100644
--- a/source/os_specific/service_layers/oswintbl.c
+++ b/source/os_specific/service_layers/oswintbl.c
@@ -41,8 +41,8 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
-
#include "acpi.h"
+#include <stdio.h>
#ifdef WIN32
#pragma warning(disable:4115) /* warning C4115: (caused by rpcasync.h) */
@@ -55,21 +55,57 @@
#define _COMPONENT ACPI_OS_SERVICES
ACPI_MODULE_NAME ("oswintbl")
+/* Local prototypes */
+
+static char *
+WindowsFormatException (
+ LONG WinStatus);
-static char KeyBuffer[64];
-static char ErrorBuffer[64];
+/* Globals */
+#define LOCAL_BUFFER_SIZE 64
-/* Little front-end to win FormatMessage */
+static char KeyBuffer[LOCAL_BUFFER_SIZE];
+static char ErrorBuffer[LOCAL_BUFFER_SIZE];
-char *
-OsFormatException (
- LONG Status)
+/*
+ * Tables supported in the Windows registry. SSDTs are not placed into
+ * the registry, a limitation.
+ */
+static char *SupportedTables[] =
+{
+ "DSDT",
+ "RSDT",
+ "FACS",
+ "FACP"
+};
+
+/* Max index for table above */
+
+#define ACPI_OS_MAX_TABLE_INDEX 3
+
+
+/******************************************************************************
+ *
+ * FUNCTION: WindowsFormatException
+ *
+ * PARAMETERS: WinStatus - Status from a Windows system call
+ *
+ * RETURN: Formatted (ascii) exception code. Front-end to Windows
+ * FormatMessage interface.
+ *
+ * DESCRIPTION: Decode a windows exception
+ *
+ *****************************************************************************/
+
+static char *
+WindowsFormatException (
+ LONG WinStatus)
{
ErrorBuffer[0] = 0;
- FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, Status, 0,
- ErrorBuffer, 64, NULL);
+ FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, WinStatus, 0,
+ ErrorBuffer, LOCAL_BUFFER_SIZE, NULL);
return (ErrorBuffer);
}
@@ -77,30 +113,120 @@ OsFormatException (
/******************************************************************************
*
- * FUNCTION: OsGetTable
+ * FUNCTION: AcpiOsGetTableByAddress
*
- * PARAMETERS: Signature - ACPI Signature for desired table. must be
- * a null terminated string.
+ * PARAMETERS: Address - Physical address of the ACPI table
+ * Table - Where a pointer to the table is returned
*
- * RETURN: Pointer to the table. NULL if failure.
+ * RETURN: Status; Table buffer is returned if AE_OK.
+ * AE_NOT_FOUND: A valid table was not found at the address
*
- * DESCRIPTION: Get an ACPI table from the Windows registry.
+ * DESCRIPTION: Get an ACPI table via a physical memory address.
+ *
+ * NOTE: Cannot be implemented without a Windows device driver.
*
*****************************************************************************/
-ACPI_TABLE_HEADER *
-OsGetTable (
- char *Signature)
+ACPI_STATUS
+AcpiOsGetTableByAddress (
+ ACPI_PHYSICAL_ADDRESS Address,
+ ACPI_TABLE_HEADER **Table)
{
- HKEY Handle = NULL;
- ULONG i;
- LONG Status;
- ULONG Type;
- ULONG NameSize;
- ULONG DataSize;
- HKEY SubKey;
- ACPI_TABLE_HEADER *ReturnTable;
+ fprintf (stderr, "Get table by address is not supported on Windows\n");
+ return (AE_SUPPORT);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsGetTableByIndex
+ *
+ * PARAMETERS: Index - Which table to get
+ * Table - Where a pointer to the table is returned
+ * Address - Where the table physical address is returned
+ *
+ * RETURN: Status; Table buffer and physical address returned if AE_OK.
+ * AE_LIMIT: Index is beyond valid limit
+ *
+ * DESCRIPTION: Get an ACPI table via an index value (0 through n). Returns
+ * AE_LIMIT when an invalid index is reached. Index is not
+ * necessarily an index into the RSDT/XSDT.
+ * Table is obtained from the Windows registry.
+ *
+ * NOTE: Cannot get the physical address from the windows registry;
+ * zero is returned instead.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsGetTableByIndex (
+ UINT32 Index,
+ ACPI_TABLE_HEADER **Table,
+ ACPI_PHYSICAL_ADDRESS *Address)
+{
+ ACPI_STATUS Status;
+
+
+ if (Index > ACPI_OS_MAX_TABLE_INDEX)
+ {
+ return (AE_LIMIT);
+ }
+
+ Status = AcpiOsGetTableByName (SupportedTables[Index], 0, Table, Address);
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiOsGetTableByName
+ *
+ * PARAMETERS: Signature - ACPI Signature for desired table. Must be
+ * a null terminated 4-character string.
+ * Instance - For SSDTs (0...n). Use 0 otherwise.
+ * Table - Where a pointer to the table is returned
+ * Address - Where the table physical address is returned
+ *
+ * RETURN: Status; Table buffer and physical address returned if AE_OK.
+ * AE_LIMIT: Instance is beyond valid limit
+ * AE_NOT_FOUND: A table with the signature was not found
+ *
+ * DESCRIPTION: Get an ACPI table via a table signature (4 ASCII characters).
+ * Returns AE_LIMIT when an invalid instance is reached.
+ * Table is obtained from the Windows registry.
+ *
+ * NOTE: Assumes the input signature is uppercase.
+ * Cannot get the physical address from the windows registry;
+ * zero is returned instead.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsGetTableByName (
+ char *Signature,
+ UINT32 Instance,
+ ACPI_TABLE_HEADER **Table,
+ ACPI_PHYSICAL_ADDRESS *Address)
+{
+ HKEY Handle = NULL;
+ LONG WinStatus;
+ ULONG Type;
+ ULONG NameSize;
+ ULONG DataSize;
+ HKEY SubKey;
+ ULONG i;
+ ACPI_TABLE_HEADER *ReturnTable;
+
+
+ /*
+ * Windows has no SSDTs in the registry, so multiple instances are
+ * not supported.
+ */
+ if (Instance > 0)
+ {
+ return (AE_LIMIT);
+ }
/* Get a handle to the table key */
@@ -109,10 +235,10 @@ OsGetTable (
ACPI_STRCPY (KeyBuffer, "HARDWARE\\ACPI\\");
ACPI_STRCAT (KeyBuffer, Signature);
- Status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, KeyBuffer,
- 0L, KEY_READ, &Handle);
+ WinStatus = RegOpenKeyEx (HKEY_LOCAL_MACHINE, KeyBuffer,
+ 0L, KEY_READ, &Handle);
- if (Status != ERROR_SUCCESS)
+ if (WinStatus != ERROR_SUCCESS)
{
/*
* Somewhere along the way, MS changed the registry entry for
@@ -126,12 +252,16 @@ OsGetTable (
{
Signature = "FADT";
}
+ else if (ACPI_COMPARE_NAME (Signature, "XSDT"))
+ {
+ Signature = "RSDT";
+ }
else
{
- AcpiOsPrintf (
- "Could not find %s in registry at %s: %s (Status=0x%X)\n",
- Signature, KeyBuffer, OsFormatException (Status), Status);
- return (NULL);
+ fprintf (stderr,
+ "Could not find %s in registry at %s: %s (WinStatus=0x%X)\n",
+ Signature, KeyBuffer, WindowsFormatException (WinStatus), WinStatus);
+ return (AE_NOT_FOUND);
}
}
else
@@ -140,23 +270,23 @@ OsGetTable (
}
}
- /* Actual data for table is down a couple levels */
+ /* Actual data for the table is down a couple levels */
for (i = 0; ;)
{
- Status = RegEnumKey (Handle, i, KeyBuffer, sizeof (KeyBuffer));
- i += 1;
- if (Status == ERROR_NO_MORE_ITEMS)
+ WinStatus = RegEnumKey (Handle, i, KeyBuffer, sizeof (KeyBuffer));
+ i++;
+ if (WinStatus == ERROR_NO_MORE_ITEMS)
{
break;
}
- Status = RegOpenKey (Handle, KeyBuffer, &SubKey);
- if (Status != ERROR_SUCCESS)
+ WinStatus = RegOpenKey (Handle, KeyBuffer, &SubKey);
+ if (WinStatus != ERROR_SUCCESS)
{
- AcpiOsPrintf ("Could not open %s entry: %s\n",
- Signature, OsFormatException (Status));
- return (NULL);
+ fprintf (stderr, "Could not open %s entry: %s\n",
+ Signature, WindowsFormatException (WinStatus));
+ return (AE_ERROR);
}
RegCloseKey (Handle);
@@ -166,38 +296,38 @@ OsGetTable (
/* Find the (binary) table entry */
- for (i = 0; ;)
+ for (i = 0; ; i++)
{
NameSize = sizeof (KeyBuffer);
- Status = RegEnumValue (Handle, i, KeyBuffer, &NameSize,
- NULL, &Type, NULL, 0);
- if (Status != ERROR_SUCCESS)
+ WinStatus = RegEnumValue (Handle, i, KeyBuffer, &NameSize, NULL,
+ &Type, NULL, 0);
+ if (WinStatus != ERROR_SUCCESS)
{
- AcpiOsPrintf ("Could not get %s registry entry: %s\n",
- Signature, OsFormatException (Status));
- return (NULL);
+ fprintf (stderr, "Could not get %s registry entry: %s\n",
+ Signature, WindowsFormatException (WinStatus));
+ return (AE_ERROR);
}
if (Type == REG_BINARY)
{
break;
}
- i += 1;
}
/* Get the size of the table */
- Status = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL, NULL, &DataSize);
- if (Status != ERROR_SUCCESS)
+ WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL,
+ NULL, &DataSize);
+ if (WinStatus != ERROR_SUCCESS)
{
- AcpiOsPrintf ("Could not read the %s table size: %s\n",
- Signature, OsFormatException (Status));
- return (NULL);
+ fprintf (stderr, "Could not read the %s table size: %s\n",
+ Signature, WindowsFormatException (WinStatus));
+ return (AE_ERROR);
}
/* Allocate a new buffer for the table */
- ReturnTable = AcpiOsAllocate (DataSize);
+ ReturnTable = malloc (DataSize);
if (!ReturnTable)
{
goto Cleanup;
@@ -205,17 +335,20 @@ OsGetTable (
/* Get the actual table from the registry */
- Status = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL,
- (UCHAR *) ReturnTable, &DataSize);
- if (Status != ERROR_SUCCESS)
+ WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL,
+ (UCHAR *) ReturnTable, &DataSize);
+ if (WinStatus != ERROR_SUCCESS)
{
- AcpiOsPrintf ("Could not read %s data: %s\n",
- Signature, OsFormatException (Status));
- AcpiOsFree (ReturnTable);
- return (NULL);
+ fprintf (stderr, "Could not read %s data: %s\n",
+ Signature, WindowsFormatException (WinStatus));
+ free (ReturnTable);
+ return (AE_ERROR);
}
Cleanup:
RegCloseKey (Handle);
- return (ReturnTable);
+
+ *Table = ReturnTable;
+ *Address = 0;
+ return (AE_OK);
}
diff --git a/source/os_specific/service_layers/oswinxf.c b/source/os_specific/service_layers/oswinxf.c
index 8a769cbd0db04..f1c567c36da6f 100644
--- a/source/os_specific/service_layers/oswinxf.c
+++ b/source/os_specific/service_layers/oswinxf.c
@@ -74,7 +74,7 @@ char TableName[ACPI_NAME_SIZE + 1];
#define ACPI_OS_DEBUG_TIMEOUT 30000 /* 30 seconds */
-/* Upcalls to application */
+/* Upcalls to AcpiExec application */
ACPI_PHYSICAL_ADDRESS
AeLocalGetRootPointer (
@@ -85,11 +85,6 @@ AeTableOverride (
ACPI_TABLE_HEADER *ExistingTable,
ACPI_TABLE_HEADER **NewTable);
-ACPI_TABLE_HEADER *
-OsGetTable (
- char *Signature);
-
-
/*
* Real semaphores are only used for a multi-threaded application
*/
@@ -245,6 +240,10 @@ AcpiOsTableOverride (
ACPI_TABLE_HEADER *ExistingTable,
ACPI_TABLE_HEADER **NewTable)
{
+#ifdef ACPI_ASL_COMPILER
+ ACPI_STATUS Status;
+ ACPI_PHYSICAL_ADDRESS Address;
+#endif
if (!ExistingTable || !NewTable)
{
@@ -271,15 +270,16 @@ AcpiOsTableOverride (
ACPI_MOVE_NAME (TableName, ExistingTable->Signature);
TableName[ACPI_NAME_SIZE] = 0;
- *NewTable = OsGetTable (TableName);
- if (*NewTable)
+ Status = AcpiOsGetTableByName (TableName, 0, NewTable, &Address);
+ if (ACPI_SUCCESS (Status))
{
AcpiOsPrintf ("Table [%s] obtained from registry, %u bytes\n",
TableName, (*NewTable)->Length);
}
else
{
- AcpiOsPrintf ("Could not read table %s from registry\n", TableName);
+ AcpiOsPrintf ("Could not read table %s from registry (%s)\n",
+ TableName, AcpiFormatException (Status));
}
#endif
@@ -1224,18 +1224,22 @@ AcpiOsReadPort (
switch (Width)
{
case 8:
+
*Value = 0xFF;
break;
case 16:
+
*Value = 0xFFFF;
break;
case 32:
+
*Value = 0xFFFFFFFF;
break;
default:
+
ACPI_ERROR ((AE_INFO, "Bad width parameter: %X", Width));
return (AE_BAD_PARAMETER);
}
@@ -1305,10 +1309,12 @@ AcpiOsReadMemory (
case 16:
case 32:
case 64:
+
*Value = 0;
break;
default:
+
return (AE_BAD_PARAMETER);
break;
}
@@ -1364,12 +1370,15 @@ AcpiOsSignal (
switch (Function)
{
case ACPI_SIGNAL_FATAL:
+
break;
case ACPI_SIGNAL_BREAKPOINT:
+
break;
default:
+
break;
}