Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1875 → Rev 2216

/drivers/devman/acpica/os_specific/service_layers/osunixdir.c
9,7 → 9,7
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
* All rights reserved.
*
* 2. License
125,6 → 125,9
 
#include "acpisrc.h"
 
/*
* Allocated structure returned from OsOpenDirectory
*/
typedef struct ExternalFindInfo
{
char *DirPathname;
217,7 → 220,9
if (!fnmatch (ExternalInfo->WildcardSpec, dir_entry->d_name, 0))
{
if (dir_entry->d_name[0] == '.')
{
continue;
}
 
str_len = strlen (dir_entry->d_name) +
strlen (ExternalInfo->DirPathname) + 2;
226,7 → 231,7
if (!temp_str)
{
printf ("Could not allocate buffer for temporary string\n");
return NULL;
return (NULL);
}
 
strcpy (temp_str, ExternalInfo->DirPathname);
238,7 → 243,7
if (err == -1)
{
printf ("stat() error - should not happen\n");
return NULL;
return (NULL);
}
 
if ((S_ISDIR (temp_stat.st_mode)
255,7 → 260,7
}
}
 
return NULL;
return (NULL);
}
 
 
284,9 → 289,21
free (DirHandle);
}
 
 
/* Other functions acpisrc uses but that aren't standard on Unix */
 
/* lowercase a string */
/*******************************************************************************
*
* FUNCTION: strlwr
*
* PARAMETERS: str - String to be lowercased.
*
* RETURN: str.
*
* DESCRIPTION: Lowercase a string in-place.
*
******************************************************************************/
 
char*
strlwr (
char *str)
/drivers/devman/acpica/os_specific/service_layers/osunixxf.c
8,7 → 8,7
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
* All rights reserved.
*
* 2. License
115,9 → 115,16
 
 
/*
* These interfaces are required in order to compile the ASL compiler under
* Linux or other Unix-like system.
* 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"
#include "amlcode.h"
#include "acparser.h"
#include "acdebug.h"
 
#include <stdio.h>
#include <stdlib.h>
126,13 → 133,8
#include <sys/time.h>
#include <semaphore.h>
#include <pthread.h>
#include <errno.h>
 
#include "acpi.h"
#include "accommon.h"
#include "amlcode.h"
#include "acparser.h"
#include "acdebug.h"
 
#define _COMPONENT ACPI_OS_SERVICES
ACPI_MODULE_NAME ("osunixxf")
 
154,7 → 156,13
 
typedef void* (*PTHREAD_CALLBACK) (void *);
 
/* Apple-specific */
 
#ifdef __APPLE__
#define sem_destroy sem_close
#endif
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsInitialize, AcpiOsTerminate
192,7 → 200,7
*
* RETURN: RSDP physical address
*
* DESCRIPTION: Gets the root pointer (RSDP)
* DESCRIPTION: Gets the ACPI root pointer (RSDP)
*
*****************************************************************************/
 
239,7 → 247,8
*
* FUNCTION: AcpiOsTableOverride
*
* PARAMETERS: ExistingTable - Header of current table (probably firmware)
* PARAMETERS: ExistingTable - Header of current table (probably
* firmware)
* NewTable - Where an entire new table is returned.
*
* RETURN: Status, pointer to new table. Null pointer returned if no
298,7 → 307,7
*
* FUNCTION: AcpiOsPrintf
*
* PARAMETERS: fmt, ... Standard printf format
* PARAMETERS: fmt, ... - Standard printf format
*
* RETURN: None
*
324,8 → 333,8
*
* FUNCTION: AcpiOsVprintf
*
* PARAMETERS: fmt Standard printf format
* args Argument list
* PARAMETERS: fmt - Standard printf format
* args - Argument list
*
* RETURN: None
*
372,18 → 381,21
*
* FUNCTION: AcpiOsGetLine
*
* PARAMETERS: fmt Standard printf format
* args Argument list
* PARAMETERS: Buffer - Where to return the command line
* BufferLength - Maximum length of Buffer
* BytesRead - Where the actual byte count is returned
*
* RETURN: Actual bytes read
* RETURN: Status and actual bytes read
*
* DESCRIPTION: Formatted input with argument list pointer
*
*****************************************************************************/
 
UINT32
ACPI_STATUS
AcpiOsGetLine (
char *Buffer)
char *Buffer,
UINT32 BufferLength,
UINT32 *BytesRead)
{
UINT8 Temp;
UINT32 i;
391,6 → 403,11
 
for (i = 0; ; i++)
{
if (i >= BufferLength)
{
return (AE_BUFFER_OVERFLOW);
}
 
scanf ("%1c", &Temp);
if (!Temp || Temp == '\n')
{
406,15 → 423,20
 
/* Return the number of bytes in the string */
 
return (i);
if (BytesRead)
{
*BytesRead = i;
}
return (AE_OK);
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsMapMemory
*
* PARAMETERS: where Physical address of memory to be mapped
* length How much memory to map
* PARAMETERS: where - Physical address of memory to be mapped
* length - How much memory to map
*
* RETURN: Pointer to mapped memory. Null on error.
*
436,8 → 458,8
*
* FUNCTION: AcpiOsUnmapMemory
*
* PARAMETERS: where Logical address of memory to be unmapped
* length How much memory to unmap
* PARAMETERS: where - Logical address of memory to be unmapped
* length - How much memory to unmap
*
* RETURN: None.
*
460,7 → 482,7
*
* FUNCTION: AcpiOsAllocate
*
* PARAMETERS: Size Amount to allocate, in bytes
* PARAMETERS: Size - Amount to allocate, in bytes
*
* RETURN: Pointer to the new allocation. Null on error.
*
484,7 → 506,7
*
* FUNCTION: AcpiOsFree
*
* PARAMETERS: mem Pointer to previously allocated memory
* PARAMETERS: mem - Pointer to previously allocated memory
*
* RETURN: None.
*
529,7 → 551,6
}
 
Sem = AcpiOsAllocate (sizeof (sem_t));
 
if (!Sem)
{
return (AE_NO_MEMORY);
756,9 → 777,9
*
* FUNCTION: AcpiOsInstallInterruptHandler
*
* PARAMETERS: InterruptNumber Level handler should respond to.
* Isr Address of the ACPI interrupt handler
* ExceptPtr Where status is returned
* PARAMETERS: InterruptNumber - Level handler should respond to.
* Isr - Address of the ACPI interrupt handler
* ExceptPtr - Where status is returned
*
* RETURN: Handle to the newly installed handler.
*
782,7 → 803,7
*
* FUNCTION: AcpiOsRemoveInterruptHandler
*
* PARAMETERS: Handle Returned when handler was installed
* PARAMETERS: Handle - Returned when handler was installed
*
* RETURN: Status
*
802,42 → 823,9
 
/******************************************************************************
*
* FUNCTION: AcpiOsExecute
*
* PARAMETERS: Type - Type of execution
* Function - Address of the function to execute
* Context - Passed as a parameter to the function
*
* RETURN: Status.
*
* DESCRIPTION: Execute a new thread
*
*****************************************************************************/
 
ACPI_STATUS
AcpiOsExecute (
ACPI_EXECUTE_TYPE Type,
ACPI_OSD_EXEC_CALLBACK Function,
void *Context)
{
pthread_t thread;
int ret;
 
 
ret = pthread_create (&thread, NULL, (PTHREAD_CALLBACK) Function, Context);
if (ret)
{
AcpiOsPrintf("Create thread failed");
}
return (0);
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsStall
*
* PARAMETERS: microseconds To sleep
* PARAMETERS: microseconds - Time to sleep
*
* RETURN: Blocks until sleep is completed.
*
861,7 → 849,7
*
* FUNCTION: AcpiOsSleep
*
* PARAMETERS: milliseconds To sleep
* PARAMETERS: milliseconds - Time to sleep
*
* RETURN: Blocks until sleep is completed.
*
882,6 → 870,7
usleep ((milliseconds % 1000) * 1000); /* Sleep for remaining usecs */
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsGetTimer
895,7 → 884,8
*****************************************************************************/
 
UINT64
AcpiOsGetTimer (void)
AcpiOsGetTimer (
void)
{
struct timeval time;
 
910,34 → 900,12
 
/******************************************************************************
*
* FUNCTION: AcpiOsValidateInterface
*
* PARAMETERS: Interface - Requested interface to be validated
*
* RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
*
* DESCRIPTION: Match an interface string to the interfaces supported by the
* host. Strings originate from an AML call to the _OSI method.
*
*****************************************************************************/
 
ACPI_STATUS
AcpiOsValidateInterface (
char *Interface)
{
 
return (AE_SUPPORT);
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsReadPciConfiguration
*
* PARAMETERS: PciId Seg/Bus/Dev
* Register Device Register
* Value Buffer where value is placed
* Width Number of bits
* PARAMETERS: PciId - Seg/Bus/Dev
* Register - Device Register
* Value - Buffer where value is placed
* Width - Number of bits
*
* RETURN: Status
*
949,7 → 917,7
AcpiOsReadPciConfiguration (
ACPI_PCI_ID *PciId,
UINT32 Register,
void *Value,
UINT64 *Value,
UINT32 Width)
{
 
961,10 → 929,10
*
* FUNCTION: AcpiOsWritePciConfiguration
*
* PARAMETERS: PciId Seg/Bus/Dev
* Register Device Register
* Value Value to be written
* Width Number of bits
* PARAMETERS: PciId - Seg/Bus/Dev
* Register - Device Register
* Value - Value to be written
* Width - Number of bits
*
* RETURN: Status.
*
983,24 → 951,14
return (AE_OK);
}
 
/* TEMPORARY STUB FUNCTION */
void
AcpiOsDerivePciId(
ACPI_HANDLE Device,
ACPI_HANDLE Region,
ACPI_PCI_ID **PciId)
{
 
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsReadPort
*
* PARAMETERS: Address Address of I/O port/register to read
* Value Where value is placed
* Width Number of bits
* PARAMETERS: Address - Address of I/O port/register to read
* Value - Where value is placed
* Width - Number of bits
*
* RETURN: Value read from port
*
1041,9 → 999,9
*
* FUNCTION: AcpiOsWritePort
*
* PARAMETERS: Address Address of I/O port/register to write
* Value Value to write
* Width Number of bits
* PARAMETERS: Address - Address of I/O port/register to write
* Value - Value to write
* Width - Number of bits
*
* RETURN: None
*
1066,9 → 1024,9
*
* FUNCTION: AcpiOsReadMemory
*
* PARAMETERS: Address Physical Memory Address to read
* Value Where value is placed
* Width Number of bits
* PARAMETERS: Address - Physical Memory Address to read
* Value - Where value is placed
* Width - Number of bits
*
* RETURN: Value read from physical memory address
*
1102,9 → 1060,9
*
* FUNCTION: AcpiOsWriteMemory
*
* PARAMETERS: Address Physical Memory Address to write
* Value Value to write
* Width Number of bits
* PARAMETERS: Address - Physical Memory Address to write
* Value - Value to write
* Width - Number of bits
*
* RETURN: None
*
1171,33 → 1129,10
 
/******************************************************************************
*
* FUNCTION: AcpiOsGetThreadId
*
* PARAMETERS: None
*
* RETURN: Id of the running thread
*
* DESCRIPTION: Get the Id of the current (running) thread
*
* NOTE: The environment header should contain this line:
* #define ACPI_THREAD_ID pthread_t
*
*****************************************************************************/
 
ACPI_THREAD_ID
AcpiOsGetThreadId (void)
{
 
return (pthread_self ());
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsSignal
*
* PARAMETERS: Function ACPI CA signal function code
* Info Pointer to function-dependent structure
* PARAMETERS: Function - ACPI CA signal function code
* Info - Pointer to function-dependent structure
*
* RETURN: Status
*
/drivers/devman/acpica/os_specific/service_layers/oswindir.c
9,7 → 9,7
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
* All rights reserved.
*
* 2. License
114,6 → 114,7
*
*****************************************************************************/
 
#include <acpi.h>
 
#include <stdio.h>
#include <stdlib.h>
120,8 → 121,6
#include <string.h>
#include <io.h>
 
#include <acpi.h>
 
typedef struct ExternalFindInfo
{
struct _finddata_t DosInfo;
171,7 → 170,7
SearchInfo = calloc (sizeof (EXTERNAL_FIND_INFO), 1);
if (!SearchInfo)
{
return NULL;
return (NULL);
}
 
/* Allocate space for the full wildcard path */
180,7 → 179,7
if (!FullWildcardSpec)
{
printf ("Could not allocate buffer for wildcard pathname\n");
return NULL;
return (NULL);
}
 
/* Create the full wildcard path */
198,7 → 197,7
 
free (FullWildcardSpec);
free (SearchInfo);
return NULL;
return (NULL);
}
 
/* Save the info in the return structure */
254,7 → 253,7
Status = _findnext (SearchInfo->FindHandle, &SearchInfo->DosInfo);
if (Status != 0)
{
return NULL;
return (NULL);
}
}
 
288,7 → 287,7
break;
 
default:
return NULL;
return (NULL);
}
}
 
302,7 → 301,7
*
* PARAMETERS: DirHandle - Created via AcpiOsOpenDirectory
*
* RETURN: None.
* RETURN: None
*
* DESCRIPTION: Close the open directory and cleanup.
*
/drivers/devman/acpica/os_specific/service_layers/oswintbl.c
8,7 → 8,7
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
* All rights reserved.
*
* 2. License
114,19 → 114,16
*****************************************************************************/
 
 
#include "acpi.h"
 
#ifdef WIN32
#pragma warning(disable:4115) /* warning C4115: (caused by rpcasync.h) */
 
#include <windows.h>
#include <winbase.h>
 
#elif WIN64
#include <windowsx.h>
#endif
 
#include "acpi.h"
#include "accommon.h"
 
#define _COMPONENT ACPI_OS_SERVICES
ACPI_MODULE_NAME ("oswintbl")
 
/drivers/devman/acpica/os_specific/service_layers/oswinxf.c
8,7 → 8,7
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
* All rights reserved.
*
* 2. License
113,6 → 113,8
*
*****************************************************************************/
 
#include "acpi.h"
#include "accommon.h"
 
#ifdef WIN32
#pragma warning(disable:4115) /* warning C4115: named type definition in parentheses (caused by rpcasync.h> */
130,32 → 132,22
#include <process.h>
#include <time.h>
 
#include "acpi.h"
#include "accommon.h"
 
#define _COMPONENT ACPI_OS_SERVICES
ACPI_MODULE_NAME ("oswinxf")
 
 
/* Semaphore information structure */
extern FILE *AcpiGbl_DebugFile;
extern BOOLEAN AcpiGbl_DebugTimeout;
 
typedef struct acpi_os_semaphore_info
{
UINT16 MaxUnits;
UINT16 CurrentUnits;
void *OsHandle;
FILE *AcpiGbl_OutputFile;
UINT64 TimerFrequency;
char TableName[ACPI_NAME_SIZE + 1];
 
} ACPI_OS_SEMAPHORE_INFO;
#define ACPI_OS_DEBUG_TIMEOUT 30000 /* 30 seconds */
 
/* Need enough semaphores to run the large aslts suite */
 
#define ACPI_OS_MAX_SEMAPHORES 256
/* Upcalls to application */
 
ACPI_OS_SEMAPHORE_INFO AcpiGbl_Semaphores[ACPI_OS_MAX_SEMAPHORES];
 
 
/* Upcalls to AcpiExec */
 
ACPI_PHYSICAL_ADDRESS
AeLocalGetRootPointer (
void);
170,16 → 162,30
char *Signature);
 
 
extern FILE *AcpiGbl_DebugFile;
extern BOOLEAN AcpiGbl_DebugTimeout;
/*
* Real semaphores are only used for a multi-threaded application
*/
#ifndef ACPI_SINGLE_THREADED
 
FILE *AcpiGbl_OutputFile;
UINT64 TimerFrequency;
char TableName[ACPI_NAME_SIZE + 1];
/* Semaphore information structure */
 
#define ACPI_OS_DEBUG_TIMEOUT 30000 /* 30 seconds */
typedef struct acpi_os_semaphore_info
{
UINT16 MaxUnits;
UINT16 CurrentUnits;
void *OsHandle;
 
} ACPI_OS_SEMAPHORE_INFO;
 
/* Need enough semaphores to run the large aslts suite */
 
#define ACPI_OS_MAX_SEMAPHORES 256
 
ACPI_OS_SEMAPHORE_INFO AcpiGbl_Semaphores[ACPI_OS_MAX_SEMAPHORES];
 
#endif /* ACPI_SINGLE_THREADED */
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsTerminate
186,7 → 192,7
*
* PARAMETERS: None
*
* RETURN: None
* RETURN: Status
*
* DESCRIPTION: Nothing to do for windows
*
193,9 → 199,10
*****************************************************************************/
 
ACPI_STATUS
AcpiOsTerminate (void)
AcpiOsTerminate (
void)
{
return AE_OK;
return (AE_OK);
}
 
 
212,17 → 219,20
*****************************************************************************/
 
ACPI_STATUS
AcpiOsInitialize (void)
AcpiOsInitialize (
void)
{
LARGE_INTEGER LocalTimerFrequency;
 
 
AcpiGbl_OutputFile = stdout;
 
#ifndef ACPI_SINGLE_THREADED
/* Clear the semaphore info array */
 
memset (AcpiGbl_Semaphores, 0x00, sizeof (AcpiGbl_Semaphores));
#endif
 
AcpiGbl_OutputFile = stdout;
 
/* Get the timer frequency for use in AcpiOsGetTimer */
 
TimerFrequency = 0;
233,7 → 243,7
TimerFrequency = LocalTimerFrequency.QuadPart;
}
 
return AE_OK;
return (AE_OK);
}
 
 
460,7 → 470,7
*
* FUNCTION: AcpiOsPrintf
*
* PARAMETERS: fmt, ... Standard printf format
* PARAMETERS: Fmt, ... - Standard printf format
*
* RETURN: None
*
489,8 → 499,8
*
* FUNCTION: AcpiOsVprintf
*
* PARAMETERS: fmt Standard printf format
* args Argument list
* PARAMETERS: Fmt - Standard printf format
* Args - Argument list
*
* RETURN: None
*
539,18 → 549,21
*
* FUNCTION: AcpiOsGetLine
*
* PARAMETERS: fmt Standard printf format
* args Argument list
* PARAMETERS: Buffer - Where to return the command line
* BufferLength - Maximum length of Buffer
* BytesRead - Where the actual byte count is returned
*
* RETURN: Actual bytes read
* RETURN: Status and actual bytes read
*
* DESCRIPTION: Formatted input with argument list pointer
*
*****************************************************************************/
 
UINT32
ACPI_STATUS
AcpiOsGetLine (
char *Buffer)
char *Buffer,
UINT32 BufferLength,
UINT32 *BytesRead)
{
char Temp;
UINT32 i;
558,6 → 571,11
 
for (i = 0; ; i++)
{
if (i >= BufferLength)
{
return (AE_BUFFER_OVERFLOW);
}
 
scanf ("%1c", &Temp);
if (!Temp || Temp == '\n')
{
573,8 → 591,12
 
/* Return the number of bytes in the string */
 
return (i);
if (BytesRead)
{
*BytesRead = i;
}
return (AE_OK);
}
 
 
/******************************************************************************
581,8 → 603,8
*
* FUNCTION: AcpiOsMapMemory
*
* PARAMETERS: where Physical address of memory to be mapped
* length How much memory to map
* PARAMETERS: Where - Physical address of memory to be mapped
* Length - How much memory to map
*
* RETURN: Pointer to mapped memory. Null on error.
*
592,11 → 614,11
 
void *
AcpiOsMapMemory (
ACPI_PHYSICAL_ADDRESS where,
ACPI_SIZE length)
ACPI_PHYSICAL_ADDRESS Where,
ACPI_SIZE Length)
{
 
return (ACPI_TO_POINTER ((ACPI_SIZE) where));
return (ACPI_TO_POINTER ((ACPI_SIZE) Where));
}
 
 
604,8 → 626,8
*
* FUNCTION: AcpiOsUnmapMemory
*
* PARAMETERS: where Logical address of memory to be unmapped
* length How much memory to unmap
* PARAMETERS: Where - Logical address of memory to be unmapped
* Length - How much memory to unmap
*
* RETURN: None.
*
616,8 → 638,8
 
void
AcpiOsUnmapMemory (
void *where,
ACPI_SIZE length)
void *Where,
ACPI_SIZE Length)
{
 
return;
628,7 → 650,7
*
* FUNCTION: AcpiOsAllocate
*
* PARAMETERS: Size Amount to allocate, in bytes
* PARAMETERS: Size - Amount to allocate, in bytes
*
* RETURN: Pointer to the new allocation. Null on error.
*
638,14 → 660,14
 
void *
AcpiOsAllocate (
ACPI_SIZE size)
ACPI_SIZE Size)
{
void *Mem;
 
 
Mem = (void *) malloc ((size_t) size);
Mem = (void *) malloc ((size_t) Size);
 
return Mem;
return (Mem);
}
 
 
653,7 → 675,7
*
* FUNCTION: AcpiOsFree
*
* PARAMETERS: mem Pointer to previously allocated memory
* PARAMETERS: Mem - Pointer to previously allocated memory
*
* RETURN: None.
*
670,8 → 692,54
}
 
 
#ifdef ACPI_SINGLE_THREADED
/******************************************************************************
*
* FUNCTION: Semaphore stub functions
*
* DESCRIPTION: Stub functions used for single-thread applications that do
* not require semaphore synchronization. Full implementations
* of these functions appear after the stubs.
*
*****************************************************************************/
 
ACPI_STATUS
AcpiOsCreateSemaphore (
UINT32 MaxUnits,
UINT32 InitialUnits,
ACPI_HANDLE *OutHandle)
{
*OutHandle = (ACPI_HANDLE) 1;
return (AE_OK);
}
 
ACPI_STATUS
AcpiOsDeleteSemaphore (
ACPI_HANDLE Handle)
{
return (AE_OK);
}
 
ACPI_STATUS
AcpiOsWaitSemaphore (
ACPI_HANDLE Handle,
UINT32 Units,
UINT16 Timeout)
{
return (AE_OK);
}
 
ACPI_STATUS
AcpiOsSignalSemaphore (
ACPI_HANDLE Handle,
UINT32 Units)
{
return (AE_OK);
}
 
#else
/******************************************************************************
*
* FUNCTION: AcpiOsCreateSemaphore
*
* PARAMETERS: MaxUnits - Maximum units that can be sent
690,12 → 758,10
UINT32 InitialUnits,
ACPI_SEMAPHORE *OutHandle)
{
#ifdef _MULTI_THREADED
void *Mutex;
UINT32 i;
 
ACPI_FUNCTION_NAME (OsCreateSemaphore);
#endif
 
 
if (MaxUnits == ACPI_UINT32_MAX)
710,11 → 776,9
 
if (InitialUnits > MaxUnits)
{
return AE_BAD_PARAMETER;
return (AE_BAD_PARAMETER);
}
 
#ifdef _MULTI_THREADED
 
/* Find an empty slot */
 
for (i = 0; i < ACPI_OS_MAX_SEMAPHORES; i++)
728,7 → 792,7
{
ACPI_EXCEPTION ((AE_INFO, AE_LIMIT,
"Reached max semaphores (%u), could not create", ACPI_OS_MAX_SEMAPHORES));
return AE_LIMIT;
return (AE_LIMIT);
}
 
/* Create an OS semaphore */
737,7 → 801,7
if (!Mutex)
{
ACPI_ERROR ((AE_INFO, "Could not create semaphore"));
return AE_NO_MEMORY;
return (AE_NO_MEMORY);
}
 
AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits;
748,9 → 812,7
i, MaxUnits, InitialUnits, Mutex));
 
*OutHandle = (void *) i;
#endif
 
return AE_OK;
return (AE_OK);
}
 
 
776,17 → 838,12
if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
!AcpiGbl_Semaphores[Index].OsHandle)
{
return AE_BAD_PARAMETER;
return (AE_BAD_PARAMETER);
}
 
 
#ifdef _MULTI_THREADED
 
CloseHandle (AcpiGbl_Semaphores[Index].OsHandle);
AcpiGbl_Semaphores[Index].OsHandle = NULL;
#endif
 
return AE_OK;
return (AE_OK);
}
 
 
810,7 → 867,6
UINT32 Units,
UINT16 Timeout)
{
#ifdef _MULTI_THREADED
UINT32 Index = (UINT32) Handle;
UINT32 WaitStatus;
UINT32 OsTimeout = Timeout;
822,13 → 878,13
if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
!AcpiGbl_Semaphores[Index].OsHandle)
{
return AE_BAD_PARAMETER;
return (AE_BAD_PARAMETER);
}
 
if (Units > 1)
{
printf ("WaitSemaphore: Attempt to receive %u units\n", Units);
return AE_NOT_IMPLEMENTED;
return (AE_NOT_IMPLEMENTED);
}
 
if (Timeout == ACPI_WAIT_FOREVER)
857,7 → 913,7
"Debug timeout on semaphore 0x%04X (%ums)\n",
Index, ACPI_OS_DEBUG_TIMEOUT));
}
return AE_TIME;
return (AE_TIME);
}
 
if (AcpiGbl_Semaphores[Index].CurrentUnits == 0)
865,13 → 921,11
ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout 0x%X, OS_Status 0x%X",
AcpiUtGetMutexName (Index), Timeout, WaitStatus));
 
return AE_OK;
return (AE_OK);
}
 
AcpiGbl_Semaphores[Index].CurrentUnits--;
#endif
 
return AE_OK;
return (AE_OK);
}
 
 
893,8 → 947,6
ACPI_SEMAPHORE Handle,
UINT32 Units)
{
#ifdef _MULTI_THREADED
 
UINT32 Index = (UINT32) Handle;
 
 
904,19 → 956,19
if (Index >= ACPI_OS_MAX_SEMAPHORES)
{
printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index);
return AE_BAD_PARAMETER;
return (AE_BAD_PARAMETER);
}
 
if (!AcpiGbl_Semaphores[Index].OsHandle)
{
printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index);
return AE_BAD_PARAMETER;
return (AE_BAD_PARAMETER);
}
 
if (Units > 1)
{
printf ("SignalSemaphore: Attempt to signal %u units, Index %2.2X\n", Units, Index);
return AE_NOT_IMPLEMENTED;
return (AE_NOT_IMPLEMENTED);
}
 
if ((AcpiGbl_Semaphores[Index].CurrentUnits + 1) >
933,14 → 985,20
AcpiGbl_Semaphores[Index].CurrentUnits++;
ReleaseSemaphore (AcpiGbl_Semaphores[Index].OsHandle, Units, NULL);
 
#endif
 
return (AE_OK);
}
 
#endif /* ACPI_SINGLE_THREADED */
 
/* Spinlock interfaces, just implement with a semaphore */
 
/******************************************************************************
*
* FUNCTION: Spinlock interfaces
*
* DESCRIPTION: Map these interfaces to semaphore interfaces
*
*****************************************************************************/
 
ACPI_STATUS
AcpiOsCreateLock (
ACPI_SPINLOCK *OutHandle)
1012,9 → 1070,9
*
* FUNCTION: AcpiOsInstallInterruptHandler
*
* PARAMETERS: InterruptNumber Level handler should respond to.
* Isr Address of the ACPI interrupt handler
* ExceptPtr Where status is returned
* PARAMETERS: InterruptNumber - Level handler should respond to.
* ServiceRoutine - Address of the ACPI interrupt handler
* Context - User context
*
* RETURN: Handle to the newly installed handler.
*
1030,7 → 1088,7
void *Context)
{
 
return AE_OK;
return (AE_OK);
}
 
 
1038,7 → 1096,7
*
* FUNCTION: AcpiOsRemoveInterruptHandler
*
* PARAMETERS: Handle Returned when handler was installed
* PARAMETERS: Handle - Returned when handler was installed
*
* RETURN: Status
*
1052,71 → 1110,17
ACPI_OSD_HANDLER ServiceRoutine)
{
 
return AE_OK;
return (AE_OK);
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsGetThreadId
*
* PARAMETERS: None
*
* RETURN: Id of the running thread
*
* DESCRIPTION: Get the Id of the current (running) thread
*
*****************************************************************************/
 
ACPI_THREAD_ID
AcpiOsGetThreadId (
void)
{
DWORD ThreadId;
 
/* Ensure ID is never 0 */
 
ThreadId = GetCurrentThreadId ();
return (ThreadId + 1);
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsExecute
*
* PARAMETERS: Type - Type of execution
* Function - Address of the function to execute
* Context - Passed as a parameter to the function
*
* RETURN: Status
*
* DESCRIPTION: Execute a new thread
*
*****************************************************************************/
 
ACPI_STATUS
AcpiOsExecute (
ACPI_EXECUTE_TYPE Type,
ACPI_OSD_EXEC_CALLBACK Function,
void *Context)
{
 
#ifdef _MULTI_THREADED
_beginthread (Function, (unsigned) 0, Context);
#endif
 
return 0;
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsStall
*
* PARAMETERS: microseconds To sleep
* PARAMETERS: Microseconds - Time to stall
*
* RETURN: Blocks until sleep is completed.
* RETURN: None. Blocks until stall is completed.
*
* DESCRIPTION: Sleep at microsecond granularity
*
1124,10 → 1128,10
 
void
AcpiOsStall (
UINT32 microseconds)
UINT32 Microseconds)
{
 
Sleep ((microseconds / 1000) + 1);
Sleep ((Microseconds / 1000) + 1);
return;
}
 
1136,9 → 1140,9
*
* FUNCTION: AcpiOsSleep
*
* PARAMETERS: milliseconds To sleep
* PARAMETERS: Milliseconds - Time to sleep
*
* RETURN: Blocks until sleep is completed.
* RETURN: None. Blocks until sleep is completed.
*
* DESCRIPTION: Sleep at millisecond granularity
*
1146,12 → 1150,12
 
void
AcpiOsSleep (
UINT64 milliseconds)
UINT64 Milliseconds)
{
 
/* Add 10ms to account for clock tick granularity */
 
Sleep (((unsigned long) milliseconds) + 10);
Sleep (((unsigned long) Milliseconds) + 10);
return;
}
 
1158,34 → 1162,12
 
/******************************************************************************
*
* FUNCTION: AcpiOsValidateInterface
*
* PARAMETERS: Interface - Requested interface to be validated
*
* RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
*
* DESCRIPTION: Match an interface string to the interfaces supported by the
* host. Strings originate from an AML call to the _OSI method.
*
*****************************************************************************/
 
ACPI_STATUS
AcpiOsValidateInterface (
char *Interface)
{
 
return (AE_SUPPORT);
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsReadPciConfiguration
*
* PARAMETERS: PciId Seg/Bus/Dev
* Register Device Register
* Value Buffer where value is placed
* Width Number of bits
* PARAMETERS: PciId - Seg/Bus/Dev
* Register - Device Register
* Value - Buffer where value is placed
* Width - Number of bits
*
* RETURN: Status
*
1197,7 → 1179,7
AcpiOsReadPciConfiguration (
ACPI_PCI_ID *PciId,
UINT32 Register,
void *Value,
UINT64 *Value,
UINT32 Width)
{
 
1209,12 → 1191,12
*
* FUNCTION: AcpiOsWritePciConfiguration
*
* PARAMETERS: PciId Seg/Bus/Dev
* Register Device Register
* Value Value to be written
* Width Number of bits
* PARAMETERS: PciId - Seg/Bus/Dev
* Register - Device Register
* Value - Value to be written
* Width - Number of bits
*
* RETURN: Status.
* RETURN: Status
*
* DESCRIPTION: Write data to PCI configuration space
*
1231,25 → 1213,14
return (AE_OK);
}
 
/* TEMPORARY STUB FUNCTION */
void
AcpiOsDerivePciId(
ACPI_HANDLE Device,
ACPI_HANDLE Region,
ACPI_PCI_ID **PciId)
{
 
return;
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsReadPort
*
* PARAMETERS: Address Address of I/O port/register to read
* Value Where value is placed
* Width Number of bits
* PARAMETERS: Address - Address of I/O port/register to read
* Value - Where value is placed
* Width - Number of bits
*
* RETURN: Value read from port
*
1290,9 → 1261,9
*
* FUNCTION: AcpiOsWritePort
*
* PARAMETERS: Address Address of I/O port/register to write
* Value Value to write
* Width Number of bits
* PARAMETERS: Address - Address of I/O port/register to write
* Value - Value to write
* Width - Number of bits
*
* RETURN: None
*
1315,9 → 1286,9
*
* FUNCTION: AcpiOsReadMemory
*
* PARAMETERS: Address Physical Memory Address to read
* Value Where value is placed
* Width Number of bits
* PARAMETERS: Address - Physical Memory Address to read
* Value - Where value is placed
* Width - Number of bits
*
* RETURN: Value read from physical memory address. Always returned
* as a 32-bit integer, regardless of the read width.
1354,9 → 1325,9
*
* FUNCTION: AcpiOsWriteMemory
*
* PARAMETERS: Address Physical Memory Address to write
* Value Value to write
* Width Number of bits
* PARAMETERS: Address - Physical Memory Address to write
* Value - Value to write
* Width - Number of bits
*
* RETURN: None
*
1379,8 → 1350,8
*
* FUNCTION: AcpiOsSignal
*
* PARAMETERS: Function ACPI CA signal function code
* Info Pointer to function-dependent structure
* PARAMETERS: Function - ACPI CA signal function code
* Info - Pointer to function-dependent structure
*
* RETURN: Status
*
1483,4 → 1454,61
return (AE_OK);
}
 
#endif
#endif /* ACPI_USE_LOCAL_CACHE */
 
 
/* Optional multi-thread support */
 
#ifndef ACPI_SINGLE_THREADED
/******************************************************************************
*
* FUNCTION: AcpiOsGetThreadId
*
* PARAMETERS: None
*
* RETURN: Id of the running thread
*
* DESCRIPTION: Get the Id of the current (running) thread
*
*****************************************************************************/
 
ACPI_THREAD_ID
AcpiOsGetThreadId (
void)
{
DWORD ThreadId;
 
/* Ensure ID is never 0 */
 
ThreadId = GetCurrentThreadId ();
return ((ACPI_THREAD_ID) (ThreadId + 1));
}
 
 
/******************************************************************************
*
* FUNCTION: AcpiOsExecute
*
* PARAMETERS: Type - Type of execution
* Function - Address of the function to execute
* Context - Passed as a parameter to the function
*
* RETURN: Status
*
* DESCRIPTION: Execute a new thread
*
*****************************************************************************/
 
ACPI_STATUS
AcpiOsExecute (
ACPI_EXECUTE_TYPE Type,
ACPI_OSD_EXEC_CALLBACK Function,
void *Context)
{
 
_beginthread (Function, (unsigned) 0, Context);
return (0);
}
 
#endif /* ACPI_SINGLE_THREADED */